Prev: RecordsetFind.htm error. Please help
Next: Error
From: Dj Psycho on 1 Jun 2006 18:07 jes my host provides PHP and i will be pleased if you could help me :-)
From: (_seb_) on 1 Jun 2006 18:48 Dj Psycho wrote: > jes my host provides PHP and i will be pleased if you could help me :-) ok, so I'll try to give you a step by step instruction: first, put all your audio files in one folder, within your main site folder, and call that folder "audio". Second, change the extension of the page in which you will have the songs playing, from htm to php. I will assume this page is also in the main site folder. If it's called 'index.html', change it to 'index.php'. Third, in code view, paste the following code, above all the rest of the code (above the doctype). Code to paste start with "<?php" and ends with "?>". <?php // GENERATE ARRAY WITH ALL AUDIO FILES if ($handle = opendir('audio')){ while (false !== ($file = readdir($handle))){ if (is_file($path.'/'.$file) && $file !== '.' && $file !== '..' && $file !== '.DS_Store'){ $files[] = $file; } } } // COUNT THE FILES $songsNum = count($files); // GENERATE RANDOM NUMBER FROM 0 TO THE NUMBER OF FILES $rand = rand(0,$songsNum-1); ?> Third, find in your code the part that concerns the embedding of window media player. It should look something like this: <object id="MediaPlayer" width="500" height="400" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"> <param name="filename" value="folder/song1.mp3"> <param name="stretchtofit" value="true"> <param name="Showcontrols" value="True"> <param name="autoStart" value="True"> <embed type="application/x-mplayer2" src="folder/song1.mp3" name="MediaPlayer"></embed> </object> In any case, in this code, there are two occurences of the link to your audio file. In the above example, these two occurences are: <param name="filename" value="folder/song1.mp3"> and: <embed type="application/x-mplayer2" src="folder/song1.mp3" name="MediaPlayer"> In both occurences, replace "folder/song1.mp3" with: <?php echo 'audio/'.$files[$rand]; ?> so that the lines will be changed to: <param name="filename" value="<?php echo 'audio/'.$files[$rand]; ?>"> and: <embed type="application/x-mplayer2" src="<?php echo 'audio/'.$files[$rand]; ?>" name="MediaPlayer"> That's all. The PHP code will look into your audio folder, and select one audio file at random each time you reload the page. Note that if you preview the page locally, it won't work. It will only work ONLINE, once you upload the page and the folder containing all the audio files. Let me know if that's clear and if it works. -- seb ( ---@webtrans1.com) http://webtrans1.com | high-end web design Downloads: Slide Show, Directory Browser, Mailing List
From: (_seb_) on 1 Jun 2006 18:55 and oh, yes, if your page was 'index.htm' and you've changed it to 'index.php', when you type your site address, it is still index.htm that will show, not index.php. To see index.php, type: http://yoursite.com/index.php If the page works properly, you can delete 'index.htm' from your remote site. (_seb_) wrote: > Dj Psycho wrote: > >> jes my host provides PHP and i will be pleased if you could help me :-) > > > ok, so I'll try to give you a step by step instruction: > > first, put all your audio files in one folder, within your main site > folder, and call that folder "audio". > > Second, change the extension of the page in which you will have the > songs playing, from htm to php. I will assume this page is also in the > main site folder. If it's called 'index.html', change it to 'index.php'. > > Third, in code view, paste the following code, above all the rest of the > code (above the doctype). Code to paste start with "<?php" and ends with > "?>". > > <?php > // GENERATE ARRAY WITH ALL AUDIO FILES > if ($handle = opendir('audio')){ > while (false !== ($file = readdir($handle))){ > if (is_file($path.'/'.$file) && $file !== '.' && $file !== '..' > && $file !== '.DS_Store'){ > $files[] = $file; > } > } > } > > // COUNT THE FILES > $songsNum = count($files); > > // GENERATE RANDOM NUMBER FROM 0 TO THE NUMBER OF FILES > $rand = rand(0,$songsNum-1); > ?> > > Third, find in your code the part that concerns the embedding of window > media player. It should look something like this: > > <object id="MediaPlayer" width="500" height="400" > classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading > Windows Media Player components..." type="application/x-oleobject" > codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"> > > <param name="filename" value="folder/song1.mp3"> > <param name="stretchtofit" value="true"> > <param name="Showcontrols" value="True"> > <param name="autoStart" value="True"> > <embed type="application/x-mplayer2" src="folder/song1.mp3" > name="MediaPlayer"></embed> > </object> > > In any case, in this code, there are two occurences of the link to your > audio file. In the above example, these two occurences are: > <param name="filename" value="folder/song1.mp3"> > and: > <embed type="application/x-mplayer2" src="folder/song1.mp3" > name="MediaPlayer"> > > In both occurences, replace "folder/song1.mp3" with: <?php echo > 'audio/'.$files[$rand]; ?> > > so that the lines will be changed to: > > <param name="filename" value="<?php echo 'audio/'.$files[$rand]; ?>"> > and: > <embed type="application/x-mplayer2" src="<?php echo > 'audio/'.$files[$rand]; ?>" name="MediaPlayer"> > > That's all. The PHP code will look into your audio folder, and select > one audio file at random each time you reload the page. > Note that if you preview the page locally, it won't work. It will only > work ONLINE, once you upload the page and the folder containing all the > audio files. > > Let me know if that's clear and if it works. > > -- seb ( ---@webtrans1.com) http://webtrans1.com | high-end web design Downloads: Slide Show, Directory Browser, Mailing List
From: Dj Psycho on 2 Jun 2006 16:58 nope not working at all :( is there a other why beside php ?? <a target=_blank class=ftalternatingbarlinklarge href="http://radiots.atspace.us/index.php">Link to php adress</a>
From: (_seb_) on 2 Jun 2006 20:01
Dj Psycho wrote: > nope not working at all :( is there a other why beside php ?? > <a target=_blank class=ftalternatingbarlinklarge href="http://radiots.atspace.us/index.php">Link to php adress</a> it should work. give a url to your page please. -- seb ( ---@webtrans1.com) http://webtrans1.com | high-end web design Downloads: Slide Show, Directory Browser, Mailing List |