Stackoverflow:
For a cs assigment I am using the following code to stream audio. However, now I would like to add the ability to stream files successively, as in a playlist, how can I modify my code to accommodate this? I would like to have a text file of filenames that my script passes through sequentially streaming each. Is this possible? I've spent a good bit of time googling yet found few relevant links.
Thanks,
CB
#!/usr/bin/perl
use strict;
use CGI::Carp qw/fatalsToBrowser/;
open(OGGFILE, "../HW1/OGG/ACDC.ogg") or die "open error";
my $buffer;
print "Content-type: audio/ogg\n\n";
binmode STDOUT;
while( read(OGGFILE, $buffer, 16384)){
print $buffer;
}
close(OGGFILE);
Update:
I've since modified my code to create a playlist and it seems to be working well. However, for this to work, I am storing my music files in my html folder, available for all to see. Is it a simple matter of changing file permissions to prevent direct linking and visibility? Is it possible for me to modify this program so that it streams the files from a folder outside of /html?
Thanks CB
#!/usr/bin/perl
use strict;
use CGI qw/:standard/;
use CGI::Pretty qw/:standard/;
use CGI::Carp qw/fatalsToBrowser/;
print header(-type=>'audio/x-mpegurl',-expires=>'now');
printf "#EXTM3U\n";
printf "#EXTINF:-1,Some ACDC song\n";
printf "http://www.mywebserver/MP3/ACDC.ogg\n";
printf "#EXTINF:-1,Some Pink Floyd Song\n";
printf "http://www.mywebserver.com/MP3/PinkFloyd.ogg\n";