Below is a simple php script to generate a playlist of the mp3 files placed in a folder. I have tested it to work with XMMS media player on FC4 and should work with others too. Substitute the path and the url of the music folder.
<?php // music_playlist.php $folder_path = './music_folder'; $folder_url = 'http://domain.tld/music_folde r/'; if ($handle = opendir($folder_path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $song_list .= $folder_url.$file."\n"; } } closedir($handle); } else { echo "Music folder does not exist!"; exit; } // send header of audio/x-mpegurl content type header('Content-type: audio/x-mpegurl'); if (preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) { header("Content-Disposition: filename=\"my_playlist.m3u\"") ; } else { header("Content-Disposition: inline; filename=\"my_playlist.m3u\"") ; } echo "$song_list"; ?>
Related Reading: Listen to mp3 songs using XMMS in Redhat/Fedora
- sandip's blog
- Login or register to post comments