User Tools

Site Tools


mp3play

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
mp3play [2006/11/13 13:22]
206.161.205.190
mp3play [2006/11/13 14:32] (current)
andi old revision restored
Line 1: Line 1:
 +====== 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.
 +
 +<code perl>
 +#​!/​usr/​bin/​perl
 +
 +$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;​
 + ​chomp($file);​
 + print "​$file\n";​
 +}
 +</​code>​
  
mp3play.txt ยท Last modified: 2006/11/13 14:32 by andi