alwaysorka Posted February 19, 2014 Share Posted February 19, 2014 (edited) I have, what I believe to be a fairly easy issue, if I can explain it succinctly. Please bear with me though, as while I'm fairly adept at certain aspects of computing...I have zero real coding knowledge so my terminology is going to be crap basically. I've been trying to get the media player I use on my website to use this .php script in my media folder to 'monitor' so I don't have to constantly update the html code when I add new songs. Unfortunately, while the media player doesn't display any errors, it only continues to buffer indefinitely. It looks as if it is finding a playlist but then not knowing what to do after that. I know this is not a media file issue as when I remove the code utilizing the .php file and just revert back to simple html the player and the files I point to work just fine. Which leads me to believe there has to be an error somewhere in the coding of the file I've attached. The site is running on a GoDaddy (I know, but I have very basic needs here) Linux server and .php initialization should be just fine from what I can tell (uploaded this test file to make sure http://isthisabstract.com/phpinfo.php). You can also pull up the uploaded .php file here (http://isthisabstract.com/music/billy.php) This is the music player I am trying to get work - http://www.sheepproductions.com/billy/ (click on advanced for the .php enabled files and script). This is the HTML script I am using - <style type='text/css'> #tumblings-player {z-index:999; background-color: #000000; width:50px; height:50px; border-radius:50px 0px 0px 0px; -moz-border-radius:50px 0px 0px 0px; color:#ffffff; position:fixed; overflow:hidden; bottom:0px; right:0px; -webkit-transition: opacity 0.8s linear;-webkit-transition: all 0.8s ease-in-out;-moz-transition: all 0.8s ease-in-out;-o-transition: all 0.8s ease-in-out;} #playericon {margin-top:25px; margin-bottom:20px; ; -webkit-transition: opacity 0.8s linear;-webkit-transition: all 0.8s ease-in-out;-moz-transition: all 0.8s ease-in-out;-o-transition: all 0.8s ease-in-out;} #tumblings-player:hover {width:200px; -moz-border-radius:0px; border-radius:0px;} #tumblings-player:hover #playericon {margin-top:10px; margin-left:0px; margin-bottom:4px;} </style> <div id='tumblings-player'><center> <div id='playericon'><a href="http://tumblings.net/post/46761388554/tumblr-music-player"><img alt="Tumblr Music Player" src="http://i122.photobucket.com/albums/o260/mhilka/minigifs/minigif01.gif"/></a></div></center> <div><embed src="http://www.isthisabstract.com/music/billy.swf?autoplay=true&phpurl=http://www.isthisabstract.com/music/billy.php" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" /> <div style="color:#000; background-color:#fff; padding:100px; font-size:10px;"><a href="http://tumblings.net/post/46761388554/tumblr-music-player">Tumblr Music Player</a></div> </div> </div> I really appreciate any thoughts or idea on how to get this sorted. Maybe a permissions issue? Obviously, you can investigate for yourself at isthisabstract.com in the bottom right corner. billy.php Edited February 19, 2014 by alwaysorka Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 19, 2014 Share Posted February 19, 2014 (edited) You should be referencing billy.swf here, not billy.php <embed src="http://www.isthisabs...music/billy.php" How your swf player works is by sending it a query string of mp3 files to play. Example billy.swf?autoplay=1&f0=file1.mp3&t0=song-title1&f1=file2.mp3&t0=sone-title2&etc.. What billy.php should be doing is to automatically build the query string of mp3 files to play, by looping over all the mp3 files found within a directory. Your code does this but it is messy and relies on an outdated coding method. How I'd code billy.php would be <?php /* --------------CONFIG--------------------------------------------------------------*/ $mp3folder = '/mp3files/'; // playmode // 0 = alphabetically file list // 1 = shuffle file list $playmode = 1; // force first file in shuffle // enter filename of the song you always wants to play first. // eg. $firstfile='mysong.mp3'; // leave blank for total shuffle eg. $firstfile=''; $firstfile = ''; /* ------------CODE---------------------------------------------------------------*/ $baseurl = 'http://'.$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); $basepath = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . $mp3folder; $mp3url = $baseurl . $mp3folder; $mp3files = array(); // find .mp3 files add to array foreach(glob($basepath . '*.mp3') as $mp3) $mp3files[] = basename($mp3); // make sure array is not empty if (!empty($mp3files)) { if($playmode == 1) shuffle($mp3files); // set the first file to play defined by $firstfile, if it is not empty if(!empty($firstfile) && $mp3files[0] != $firstfile) { // find the file, get its key $key = array_search($firstfile, $mp3files); unset($mp3files[$key]); // remove file from array array_unshift($mp3files, $firstfile); // add file as first item in array $mp3files = array_values($mp3files); // amend array keys } // Build the query string $queryString = 'autoplay=true&total='.count($mp3files).'&'; foreach($mp3files as $i => $mp3file) { $queryString .= "f{$i}=$mp3url$mp3file&"; $queryString .= "t{$i}=$mp3file&"; } $queryString = trim($queryString, '&'); // outout the embed code for the mp3 player echo '<embed src="'.$baseurl.'/billy.swf?'.$queryString.'" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" />'; } else { // echo error echo '<div style="color:red;font-weight:bold">Cannot find mp3 files in ' . $mp3url . '!</div>'; } You'd call billy.php in your html using <div id='tumblings-player'> <center><div id='playericon'><a href="http://tumblings.net...lr-music-player"><img alt="Tumblr Music Player" src="http://i122.photobucket.com/albums/o260/mhilka/minigifs/minigif01.gif"/></a></div></center> <?php include 'billy.php'; /* generates webplayer html, or displays an error */ ?> <div style="color:#000; background-color:#fff; padding:100px; font-size:10px;"><a href="http://tumblings.net...lr-music-player">Tumblr Music Player</a></div> </div> </div> Edited February 19, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
alwaysorka Posted February 19, 2014 Author Share Posted February 19, 2014 Thanks man. Really appreciate the help and time. This makes more sense to me and I'll try it out here later tonight...thanks again. Quote Link to comment Share on other sites More sharing options...
alwaysorka Posted February 19, 2014 Author Share Posted February 19, 2014 (edited) So, I was looking at your suggestion about referencing billy.swf instead of .php at the beginning of your post and was confused because my code was showing I had done that correctly. Finally figured out that when I quoted it in the original post it makes it look that way. Here is the full code without it being automatically pared down. I've also attached the file, just in case. So far I've changed the billy.php file to your recommendations and uploaded it. But am getting a playlist error, I see you have some file structure searching going on in the .php file and right now I have the .swf and .php just sitting in the same folder as my music (the music is just .mp3's loaded straight into the folder, no file structure according to artist/album/song etc...) do I need to change this? I'm getting a "error playlist" message in my player now, not sure if this is because of the html code of the file structure. <div id='tumblings-player'><center> <div id='playericon'><a href="http://tumblings.net/post/46761388554/tumblr-music-player"><img alt="Tumblr Music Player" src="http://i122.photobucket.com/albums/o260/mhilka/minigifs/minigif01.gif"/></a></div></center> <div><embed src="http://www.isthisabstract.com/music/billy.swf?autoplay=true&phpurl=http://www.isthisabstract.com/music/billy.php" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" /> <div style="color:#000; background-color:#fff; padding:100px; font-size:10px;"><a href="http://tumblings.net/post/46761388554/tumblr-music-player">Tumblr Music Player</a></div> </div> </div> PS: the board automatically keeps abbreviating the code, a mouse over should show it correctly or I've attached the file below (as a .php because the forum wouldn't accept a simple .txt) code.php Edited February 19, 2014 by alwaysorka Quote Link to comment Share on other sites More sharing options...
alwaysorka Posted February 19, 2014 Author Share Posted February 19, 2014 Long story short, is it the file structure I need to change or the code portion I attached above. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 19, 2014 Share Posted February 19, 2014 (edited) You have now changed how the playlist is being sent to your swf, you have changed from this, where you are building a querystring of all files in the directory <embed src="billy.swf?autoplay=1&f0=file1.mp3&t0=song-title1&f1=file2.mp3&t0=sone-title2&etc.. ." ... /> To <embed src="http://www.isthisabstract.com/music/billy.swf?autoplay=true&phpurl=http://www.isthisabstract.com/music/billy.php" So how is your swf file reading the phpurl querystring parameter? I do not know how flash/actionscript handles this. As it stands, the code I provided for billy.php will only add .mp3 files to the playlist (it will ignore any other files). It'll then build the querystring (as your original code was trying to do) into the format posted above. It'll then return the embed html tag comlete with the formatted querystring. So if you had file1.mp3 and file2.mp3 in your folder my script will return this html <embed src="http://site.com/billy.swf?autoplay=1&f0=http://site.com/file1.mp3&t0=file1.mp3&f1=http://site.com/file2.mp3&t0=file2.mp3" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" /> I have tested my code with the swf file provided by your site when clicking the advanced link. Edited February 19, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
alwaysorka Posted February 19, 2014 Author Share Posted February 19, 2014 Yes, the code I uploaded in the code.php file is the exact same code I was using before the changes to the .php you made (I just uploaded it that way because it abbreviates and I wanted to avoid any confusion). I know I haven't properly changed the html code to match the new .php you have provided me. I'm essentially asking exactly what should it be? The code you provided in your first reply (copied below) doesn't reference the .swf that I'm assuming needs to be mentioned. I don't know how and where that should be incorporated into the code. <div id='tumblings-player'> <center><div id='playericon'><a href="http://tumblings.net...lr-music-player"><img alt="Tumblr Music Player" src="http://i122.photobucket.com/albums/o260/mhilka/minigifs/minigif01.gif"/></a></div></center> <?php include 'billy.php'; /* generates webplayer html, or displays an error */ ?> <div style="color:#000; background-color:#fff; padding:100px; font-size:10px;"><a href="http://tumblings.net...lr-music-player">Tumblr Music Player</a></div></div></div> Sorry if I seem like I'm being obtuse, but like I alluded to before, at the end of the day I'm not much more proficient at any code other than the ability to copy and paste it... Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 19, 2014 Share Posted February 19, 2014 (edited) The code you provided in your first reply (copied below) doesn't reference the .swf that I'm assuming needs to be mentioned. it is mentioned, billy.php echo's the <embed> tag to the page. The code that does this is echo '<embed src="'.$baseurl.'/billy.swf?'.$queryString.'" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" />'; The alternative would be to delete that line of code from billy.php. Now add the following line code <embed src="<?php echo $baseurl; ?>/billy.swf?<?php echo $queryString; ?>" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" />'; After <?php include 'billy.php'; /* generates webplayer html, or displays an error */ ?>. And you'll get the same result. Edited February 19, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
alwaysorka Posted February 19, 2014 Author Share Posted February 19, 2014 (edited) OK, I understand now, it's not necessary to reference the .swf in the html code because the .php file takes care of this, correct? As of right now, I copied the original code you provided into my html and unfortunately the player is still not working, with neither a buffering or playlist error. I did add a <div> tag to your original code as it was driving my page off to the left margin without it. <div id='tumblings-player'> <center><div id='playericon'><a href="http://tumblings.net...lr-music-player"><img alt="Tumblr Music Player" src="http://i122.photobucket.com/albums/o260/mhilka/minigifs/minigif01.gif"/></a></div></center> <div><?php include 'billy.php'; /* generates webplayer html, or displays an error */ ?> <div style="color:#000; background-color:#fff; padding:100px; font-size:10px;"><a href="http://tumblings.net...lr-music-player">Tumblr Music Player</a></div></div></div> This is the exact code I am using. And I have your .php, the .swf and mp3 all sitting in the same folder. I don't know if it was clear before in my first post but all of this is in a /music/ folder one level down from the public_html folder. I don't see anything in the .php or html code specifying this but it may not be needed. Edited February 19, 2014 by alwaysorka Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 20, 2014 Share Posted February 20, 2014 (edited) As of right now, I copied the original code you provided into my html and unfortunately the player is still not working, with neither a buffering or playlist error. What file is this code in? <div id='tumblings-player'> <center><div id='playericon'><a href="http://tumblings.net...r-music-player"><img alt="Tumblr Music Player" src="http://i122.photobuc.../minigif01.gif"/></a></div></center> <div><?php include 'billy.php'; /* generates webplayer html, or displays an error */ ?> <div style="color:#000; background-color:#fff; padding:100px; font-size:10px;"><a href="http://tumblings.net...r-music-player">Tumblr Music Player</a></div> </div> </div> Does the file end in a .php extensions? If it does not then you'll need to rename the file so it does ends in a .php extension. Otherwise the php include will not be executed, and subsequently the music player wont load. Edited February 20, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
alwaysorka Posted February 20, 2014 Author Share Posted February 20, 2014 This is the exact file I have uploaded. This file, the .swf and the mp3's are all sitting in a folder called /music/. So basically /public_html/musicI'm not sure if the html code needs to reflect this folder or the code in the .php. As you can see if you go to isthisabstract.com...the player does not seem to be building anything which leads me to believe it isn't initializing even the .swf either. Just displaying the CSS and .gif. I don't know that, just guessing. billy.php Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 20, 2014 Share Posted February 20, 2014 (edited) the index.html needs to be saved as index.php Also I forgot to mention, you will need to change include 'billy.php'; to include 'music/billy.php'; Also change $mp3folder = '/mp3files/'; to $mp3folder = '/music/'; Edited February 20, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
alwaysorka Posted February 20, 2014 Author Share Posted February 20, 2014 Nailed it. Made all the changes and also updated the line in the .php to point towards "/music/billy.swf" instead of just "billy.swf"Can't thank you enough for sticking with me. Quote Link to comment Share on other sites More sharing options...
alwaysorka Posted February 20, 2014 Author Share Posted February 20, 2014 (edited) One last question...I realize since the .php is building the playlist of files randomly that it's not necessarily capable of providing a display name for each. Is there a way I can remove the ".mp3" file designation from the display name in the player? I can rename the .mp3 files fairly easily enough before I upload them in "Artist - Song Title" format but I'd like to get rid of the .mp3 display if at all possible. I attached the new working .php below for convenience. billy.php Edited February 20, 2014 by alwaysorka Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 20, 2014 Share Posted February 20, 2014 Yes, change $queryString .= "t{$i}=$mp3file&"; to $queryString .= "t{$i}=" . substr($mp3file, 0, strlen($mp3file)-4) . '&'; Quote Link to comment Share on other sites More sharing options...
KamijouTouma Posted April 14, 2014 Share Posted April 14, 2014 (edited) i fixed the php file it now works and im running it the old version anyway they had things in there that were wrong and also the flash has a function that reads phpurl proof of it working at http://mf648animes.tv/music/billy.php < only online at certain times of the day since im using xampp to host on my laptop the contents of the billy.swf after decompilation movie '................\billy.swf' { // flash 7, total frames: 20, frame rate: 40 fps, 200x10 px frame 1 { function playmusic() { s.stop(); delete s; button_stop._visible = true; button_play._visible = false; s = new Sound(); _root.masterfadeout = false; _root.busy_loading = true; s.onSoundComplete = function () { ++track; if (track > lv.total - 1) { track = 0; } playmusic(); }; s.loadSound(lv['file' + track], true); gotoAndPlay(2); } function stopmusic() { button_stop._visible = false; button_play._visible = true; title = ''; _root.masterfadeout = true; _root.busy_loading = false; s.stop(); delete s; } playlistok = false; stop(); button_play._visible = false; track = 0; title = 'inititializing...'; lv = new LoadVars(); lv.onLoad = function () { if (lv.file0 == undefined) { title = 'error playlist'; button_stop._visible = false; button_play._visible = true; return undefined; } else { playlistok = true; } if (autoplay == 'true') { playmusic(); } else { title = lv['title' + track]; button_stop._visible = false; button_play._visible = true; } }; if (phpurl != undefined) { title = 'loading playlist...' + phpurl; lv.load(phpurl); } else { title = 'making playlist...'; if (total == undefined or f0 == undefined) { title = 'error playlist'; button_stop._visible = false; button_play._visible = true; return undefined; } else { playlistok = true; } var i = 0; while (i < total) { lv['file' + i] = this['f' + i]; lv['title' + i] = this['t' + i]; ++i; } lv.total = total; if (autoplay == 'true') { playmusic(); } else { title = lv['title' + track]; button_stop._visible = false; button_play._visible = true; } } } frame 1 { function aboutItem(obj, item) { getURL('http://www.sheepproductions.com/billy/', ''); } var myContextMenu = new ContextMenu(); myContextMenu.hideBuiltInItems(); myContextMenu.customItems.push(new ContextMenuItem('About &Billy...', aboutItem)); this.menu = myContextMenu; } button 3 { on (release) { if (playlistok) { ++track; if (track > lv.total - 1) { track = 0; } playmusic(); gotoAndPlay(2); } } } button 8 { on (release) { if (playlistok) { play(); playmusic(); } } } button 11 { on (release) { stop(); stopmusic(); } } movieClip 13 { } movieClip 14 { frame 1 { if (beenhere != true) { bars = new Array(bar0, bar1, bar2); barstresh = new Array(0, 0, 0); bars[0]._width = 20; bars[1]._width = 18; bars[2]._width = 16; beenhere = true; } ++accent; if (accent >= 6) { accent = 0; } i = 0; while (i < 3) { barvar = bars[i]; bartresh = barstresh[i]; if (_root.busy_loading == true) { bars[i]._width = 2; bars[i]._alpha = 100; bars[i]._visible = false; bars[int(accent / 2)]._visible = true; } else { if (barvar._width <= bartresh and _root.masterfadeout == false) { bars[i]._visible = true; barvar._width = barvar._width + 10 + random(10); bartresh = random(10); barvar._alpha = 100; } else { bars[i]._visible = true; barvar._width -= 1; barvar._alpha -= 5; } } ++i; } } } frame 2 { title = s.position + ' : ' + lv['title' + track]; if (s.position > 0) { _root.busy_loading = false; title = lv['title' + track]; } else { title = 'buffering ' + lv['title' + track]; } } frame 20 { gotoAndPlay(2); } } yes i replaced the path since i dont want others knowing it this works too http://mf648animes.tv/music/billy.swf?autoplay=true&phpurl=http://mf648animes.tv/music/billy.php enjoy billy.php Edited April 14, 2014 by KamijouTouma Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.