User Tools

Site Tools


play .m3u playlists via http

All my mp3s are stored on my filesever. Normally I just mount the mp3 directory on my current workstation (either via NFS or Samba). I have some playlists too which store all files with relative paths (relative to the playlist location). This works fine.

But sometimes I want to have an easy way to listen to a playlist without mounting anything (eg. when using the laptop). So I made the mp3 files and playlists available on my local Apache webserver and use the following short CGI to get a playlist with http adresses to the file.

$WEBDIR = '/var/www';
$WEBSERVER = 'xerxes';
use CGI;
use File::Basename;
print "Content-type: audio/x-mpegurl\r\n\r\n";
$q = new CGI();
$list = $q->param('list');
$dir  = dirname($list);
$list = $WEBDIR.'/'.$list;
open (LIST, $list) or die("Could not read $list");
@m3u = <LIST>;
close LIST;
foreach $file (@m3u){
 $file = 'http://'.$WEBSERVER.$dir.'/'.$file;
 print "$file\n";
mp3play.txt · Last modified: 2006/11/13 14:32 by andi