Forum Moderators: coopster
I have a media player with the following parameters:
----------------------------------------------
<script type='text/javascript'>
var so = new SWFObject('myplayer.swf','ply','300','28','9','#ffffff');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('file','audio/asong.mp3');
so.write('playerbox');
</script>
------------------------------------------------
That works fine for one mp3 file.
How do i dynamically load mp3 files into the media player?
I would like to load all my mp3 files into the folder "audio" on the website.
I would then like to be able to link to any of those files (click to listen) and when someone clicks on the link, the mp3 (for example - awesome.mp3) plays via the media player.
The site is on a MySQL database.
I am learning php but am not yet able to do stuff like this.
Thanks.
<script type='text/javascript'>
var so = new SWFObject('myplayer.swf','ply','300','28','9','#ffffff');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');//begin php code here
<?
//open directory of mp3 files
//while dir is open, retrieve all files ending in .mp3.
//echo "so.addVariable('file', $fileName)";
?>so.write('playerbox');
</script>
This method is simplest, however, if you have a lot of mp3s, the view source would return a super long html. The more practical solution (if you have a lot of mp3s to load) is to instead load a playlist instead of the each individual mp3. Good luck!
To do this, you are going to need to modify the Flash player itself so is supports a "playlist." By the looks of it, this player only imports one at a time.
You could devise a series of links, that when clicked change the value of "file," but a more stable method would be to modify the player. Then you'd addVariable('music-directory'.... and the flash could build an internal list. Or you could use XML methods, but at any rate a single-item player can't do this without modification, or by the link method mentioned above.