Apache::MP3 send_playlist()

This is the code that sends a playlist to the browser.

sub send_playlist {
  my $r = shift;
  my $files = shift;
  my ($path) = $r->uri =~ m!^(.*)/[^/]*$!;
  $path =~ s!([^a-zA-Z0-9/])!uc sprintf("%%%02x",ord($1))!eg;
  $r->send_http_header('audio/mpegurl');
  for my $f (@$files) {
    my $url = 'http://' . $r->hostname  . ":" 
      . $r->get_server_port
	. "$path/" . escape($f);
    $r->print ("$url?stream=1\r\n");
  }
}


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Sun Jun 4 12:45:50 PDT 2000