Goodwin Posted January 6, 2007 Share Posted January 6, 2007 Hiya,I am wondering if anyone knows about any scripts out there that use all the mp3/wma in a selected directory and when clicked the chosen song is loaded up in a seperate frame in with this script in [b]<embed height=44 volume=-1 loop=true src=Selected URL in Here' width='310' autostart='true'></embed>[/b] i have been told i need it to be a variable in a PHP script.Any Help will be greatThanksDanny Link to comment https://forums.phpfreaks.com/topic/33033-directory-to-media-player-variable-please-help/ Share on other sites More sharing options...
michaellunsford Posted January 6, 2007 Share Posted January 6, 2007 You can all files in a certain directory pretty simply using the opendir() and readdir() commands. Here's a good place to start:http://us3.php.net/manual/fi/function.opendir.phpOnce you have the gist of it, you can write another php script that displays your <embed> tag, and fills in the filename it was provided. Example from the manual (somewhat altered):[code]<?php$dir = "/some/directory/you/specify/";// Open a known directory, and proceed to read its contentsif (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(substr($file,0,1)!=".") { $file_ext=end(explode(".",$file)); if($file_ext=="mp3" OR $file_ext=="wma") echo "<a href=\"embed.php?file="$file."\">".$file."</a><br />"; } } closedir($dh); }}?>[/code]that will create links like "embed.php?file=somefile.wmv".next part [code]<?php//embed.php$dir = "/some/directory/you/specify/";echo "<embed height=44 volume=-1 loop=true src='".$_GET['file']."' width='310' autostart='true'></embed>";?>[/code]keep in mind this is not your perfect world scenario, but a good shove in the right direction. Link to comment https://forums.phpfreaks.com/topic/33033-directory-to-media-player-variable-please-help/#findComment-153895 Share on other sites More sharing options...
kateland Posted January 6, 2007 Share Posted January 6, 2007 Here's another shove...I got a different take on your question than the guy above me...if you're asking how do you call a media player to queue up all the mp3s sitting in a directory, I did something similar by reading the directory, opening an m3u file, writing all the file names into the m3u and then passing the m3u filename to the media player - instant playlist based on the directory contents. I'd post code, but it was done as a mod to phpBB and is pretty involved. Link to comment https://forums.phpfreaks.com/topic/33033-directory-to-media-player-variable-please-help/#findComment-153926 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.