Hi again all, Is there a way I can have a form generated by PHP a list all the songs I have on my server... e.g someone comes onto my site looks through the music list, selects the track they want then it plays it. Basically because i am going to be uploading A LOT of files i dont want to have to list them all in the html or xml file. so i need the PHP to read the file name and creat a link to it or load it into a player. Thanks
you can follow that way; 1-Read dir 2-divide names (pop/john/1.mp3 => string1="pop", string2="john", string3="1.mp3") you can do it using explode function 3-then, you can categorise them, or you can what you wabt. if you want to link to mp3 directly, you can do it using code like; echo '<a href="http://www.xxxxx.com/'.$string1.'/'.$string2.'/'.$string3'">$string3</a>';
<?php foreach(glob('*.mp3') as $file) { echo $file."<br />\r\n"; } PHP: That should get you started, for more info refer to the glob() php.net documentation page.
$f = opendir("mp3"); while($mp3 = Â readdir($f)) { if ($mp3 != "." &&Â $mp3 != "..") { echo "<a href='mp3/".$mp3."'>$mp3</a>"; } } PHP: hope that helps
that works fantastic thanks! is it posiable that when you click on it, it will load into a new page with a proper player - OR - if i can have the list and player on one page and it will just 'load' load it into the player? also is it possable to 'filter' out the .mp3 part?
filter out? umm, about that loader, yes it's possible but you should ... umm, I think it's client side or you have to done it via changing some php informations so you will have to call php ... I will look for something, wait
umm. $f = opendir("mp3"); while($mp3 = readdir($f)) { if ($mp3 != "." && $mp3 != "..") { echo "<a href='mp3.php?file=".$mp3."'>$mp3</a>"; } } PHP: now create new php file mp3.php and put there this <?php echo '<body marginwidth="0" marginheight="0"><embed width="100%" height="100%" name="plugin" src="mp3/'.$_GET['file'].'" type="audio/mpeg"></body>'; PHP:
am i able to put that code it work in here somehow? <OBJECT id='mediaPlayer1' width="180" height="50" classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'> <param name='fileName' value="Stream URL or Full File Path Goes Here"> <param name='animationatStart' value='true'> <param name='transparentatStart' value='true'> <param name='autoStart' value="false"> <param name='showControls' value="true"> <param name ="ShowAudioControls"value="true"> <param name="ShowStatusBar" value="true"> <param name='loop' value="false"> <EMBED type='application/x-mplayer2' pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1' bgcolor='darkblue' showcontrols="true" showtracker='-1' showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="420" height="380" src="Stream URL or Full File Path Goes Here" autostart="true" designtimesp='5311' loop="false"> </EMBED> </OBJECT> HTML:
<OBJECT id='mediaPlayer1' width="180" height="50" classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'> <param name='fileName' value="mp3/<?php echo $_GET['file']; ?>"> <param name='animationatStart' value='true'> <param name='transparentatStart' value='true'> <param name='autoStart' value="false"> <param name='showControls' value="true"> <param name ="ShowAudioControls"value="true"> <param name="ShowStatusBar" value="true"> <param name='loop' value="false"> <EMBED type='application/x-mplayer2' pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1' bgcolor='darkblue' showcontrols="true" showtracker='-1' showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="420" height="380" src="mp3/<?php echo $_GET['file']; ?>" autostart="true" designtimesp='5311' loop="false"> </EMBED> </OBJECT> PHP:
i always forget the dam echo's!! i tried to do that but left them out, evidently wouldn't work. i know it needs them just dam forget
if it don't work for you now (this code I gave you), sorry I forgot one "/" so put it again and it will work ... (edited it) Don't worry, I was forgoting ";" when I was starting with php
and another problem rises!! it is now putting in ./mp3s/Nelly , rather than ./mp3s/Nelly & Keri Hilson - Liv Tonight.mp3
hmm if you see list of these mp3's, do you see link to mp3.php?file=Nelly & Keri Hilson.mp3 or mp3.php?file=Nelly ?
yep, I think Microshit can't handle that. try this code, don't worry about browser, it will work <oBJECT> <EMBED. width="420" height="380" src="mp3/'.$_GET["file"].'" autostart="true" designtimesp="5311" loop="false"> </EMBED> </OBJECT> PHP:
mate trust me if i had my way i would be on mac or linux!! My laptop will not let me change to any other OS for some strainge reason! and sadly cannot afford a mac right now. anyway as you may be able to see, NO PLAYER AGAIN! chrome and firefox will not read the code!