Connecting Tech Pros Worldwide Forums | Help | Site Map

Winamp does not load playlist when sending m3u file using php-script

Emil
Guest
 
Posts: n/a
#1: Jul 17 '05
This is my problem:

I'm writing a script that...
1. creates a customized pls/m3u playlist
2. sends the pls or a m3u playlist to the webbrowser.

The browser should open Winamp/Windows Media Player and load the
downloaded playlist.


However this doesnt seem to work. Everything winamp shows is the
playlist-filename. It seems that the playlist-file that was sent to
Internet Explorer does not exist when winamp tries to read it.

If I take the output of the script and places it in a .m3u-file
everything will
work perfect, but I do not want a .m3u-file for each of my mp3s!

This is the code for my script:
-----------------------------------------------------------
<?php
include ('playlist.php'); // include playlist-class

$playlist = new Playlist("m3u"); // Create instance of playlist
$output = $playlist->getPlaylist(); // Generate dynamic playlist

header("Content-Type: audio/mpegurl");
header("Content-Disposition: filename=playlist.m3u");

print($output);
?>
-----------------------------------------------------------

Dan Tripp
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Winamp does not load playlist when sending m3u file using php-script


Emil wrote:[color=blue]
> This is my problem:
>
> I'm writing a script that...
> 1. creates a customized pls/m3u playlist
> 2. sends the pls or a m3u playlist to the webbrowser.
>
> The browser should open Winamp/Windows Media Player and load the
> downloaded playlist.
>
>
> However this doesnt seem to work. Everything winamp shows is the
> playlist-filename. It seems that the playlist-file that was sent to
> Internet Explorer does not exist when winamp tries to read it.
>
> If I take the output of the script and places it in a .m3u-file
> everything will
> work perfect, but I do not want a .m3u-file for each of my mp3s!
>
> This is the code for my script:
> -----------------------------------------------------------
> <?php
> include ('playlist.php'); // include playlist-class
>
> $playlist = new Playlist("m3u"); // Create instance of playlist
> $output = $playlist->getPlaylist(); // Generate dynamic playlist
>
> header("Content-Type: audio/mpegurl");
> header("Content-Disposition: filename=playlist.m3u");
>
> print($output);
> ?>
> -----------------------------------------------------------[/color]


Hiya!

I'm wondering if there isn't something askew with the playlist class.

I uploaded an .m3u playlist up to my server, then wrote a php file to
read it and echo it out with the headers. IE and Mozilla will both ask
if I want to open it in the default app (Moz wants the file to have
".m3u" at the end, which could be passed as a bogus parameter. ie.:
playlist.php?.m3u)

Here's what worked for me:

================================================== =========================
test.m3u:
================================================== =========================
#EXTM3U
#EXTINF:213,01 - The DTs - Travis.mp3
http://www.servername.com/01_-_The_DTs_-_Travis.mp3
#EXTINF:201,09 - The DTs - Jam in A (The Stoned Paradigm).mp3
http://www.servername.com/09_-_The_D..._Paradigm).mp3

================================================== =========================
playlist.php
================================================== =========================
<?php

$fileName = "./test.m3u";
$fp = fopen($fileName,"r");
$contents = fread($fp,filesize($fileName));

header("Content-Type: audio/mpegurl");
header("Content-Disposition: filename=playlist.m3u");

echo $contents;

?>
================================================== =========================

Regards,

- Dan
http://blog.dantripp.com/
Emil
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Winamp does not load playlist when sending m3u file using php-script


Dan Tripp <thisIsNot@MyEMailAddress.com> wrote in message news:<aFzTb.20890$1Y2.14493@newssvr25.news.prodigy .com>...[color=blue]
> Emil wrote:[color=green]
> > This is my problem:
> >
> > I'm writing a script that...
> > 1. creates a customized pls/m3u playlist
> > 2. sends the pls or a m3u playlist to the webbrowser.
> >
> > The browser should open Winamp/Windows Media Player and load the
> > downloaded playlist.
> >
> >
> > However this doesnt seem to work. Everything winamp shows is the
> > playlist-filename. It seems that the playlist-file that was sent to
> > Internet Explorer does not exist when winamp tries to read it.
> >
> > If I take the output of the script and places it in a .m3u-file
> > everything will
> > work perfect, but I do not want a .m3u-file for each of my mp3s!
> >
> > This is the code for my script:
> > -----------------------------------------------------------
> > <?php
> > include ('playlist.php'); // include playlist-class
> >
> > $playlist = new Playlist("m3u"); // Create instance of playlist
> > $output = $playlist->getPlaylist(); // Generate dynamic playlist
> >
> > header("Content-Type: audio/mpegurl");
> > header("Content-Disposition: filename=playlist.m3u");
> >
> > print($output);
> > ?>
> > -----------------------------------------------------------[/color]
>
>
> Hiya!
>
> I'm wondering if there isn't something askew with the playlist class.
>
> I uploaded an .m3u playlist up to my server, then wrote a php file to
> read it and echo it out with the headers. IE and Mozilla will both ask
> if I want to open it in the default app (Moz wants the file to have
> ".m3u" at the end, which could be passed as a bogus parameter. ie.:
> playlist.php?.m3u)
>
> Here's what worked for me:
>
> ================================================== =========================
> test.m3u:
> ================================================== =========================
> #EXTM3U
> #EXTINF:213,01 - The DTs - Travis.mp3
> http://www.servername.com/01_-_The_DTs_-_Travis.mp3
> #EXTINF:201,09 - The DTs - Jam in A (The Stoned Paradigm).mp3
> http://www.servername.com/09_-_The_D..._Paradigm).mp3
>
> ================================================== =========================
> playlist.php
> ================================================== =========================
> <?php
>
> $fileName = "./test.m3u";
> $fp = fopen($fileName,"r");
> $contents = fread($fp,filesize($fileName));
>
> header("Content-Type: audio/mpegurl");
> header("Content-Disposition: filename=playlist.m3u");
>
> echo $contents;
>
> ?>
> ================================================== =========================
>
> Regards,
>
> - Dan
> http://blog.dantripp.com/[/color]

Thanks for your help!


I have now solved the problem:

Before I tried to send the headers I started a session with:
session_start();

....when I removed this line, everything worked perfect!

/E
Dan Tripp
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Winamp does not load playlist when sending m3u file using php-script


Emil wrote:
[color=blue]
> Dan Tripp <thisIsNot@MyEMailAddress.com> wrote in message news:<aFzTb.20890$1Y2.14493@newssvr25.news.prodigy .com>...
>[color=green]
>>Emil wrote:
>>[color=darkred]
>>>This is my problem:
>>>
>>>I'm writing a script that...
>>>1. creates a customized pls/m3u playlist
>>>2. sends the pls or a m3u playlist to the webbrowser.
>>>
>>>The browser should open Winamp/Windows Media Player and load the
>>>downloaded playlist.
>>>
>>>
>>>However this doesnt seem to work. Everything winamp shows is the
>>>playlist-filename. It seems that the playlist-file that was sent to
>>>Internet Explorer does not exist when winamp tries to read it.
>>>
>>>If I take the output of the script and places it in a .m3u-file
>>>everything will
>>>work perfect, but I do not want a .m3u-file for each of my mp3s!
>>>
>>>This is the code for my script:
>>>-----------------------------------------------------------
>>><?php
>>> include ('playlist.php'); // include playlist-class
>>>
>>> $playlist = new Playlist("m3u"); // Create instance of playlist
>>> $output = $playlist->getPlaylist(); // Generate dynamic playlist
>>>
>>> header("Content-Type: audio/mpegurl");
>>> header("Content-Disposition: filename=playlist.m3u");
>>>
>>> print($output);
>>>?>
>>>-----------------------------------------------------------[/color]
>>
>>
>>Hiya!
>>
>>I'm wondering if there isn't something askew with the playlist class.
>>
>>I uploaded an .m3u playlist up to my server, then wrote a php file to
>>read it and echo it out with the headers. IE and Mozilla will both ask
>>if I want to open it in the default app (Moz wants the file to have
>>".m3u" at the end, which could be passed as a bogus parameter. ie.:
>>playlist.php?.m3u)
>>
>>Here's what worked for me:
>>
>>================================================ ===========================
>>test.m3u:
>>================================================ ===========================
>>#EXTM3U
>>#EXTINF:213,01 - The DTs - Travis.mp3
>>http://www.servername.com/01_-_The_DTs_-_Travis.mp3
>>#EXTINF:201,09 - The DTs - Jam in A (The Stoned Paradigm).mp3
>>http://www.servername.com/09_-_The_D..._Paradigm).mp3
>>
>>================================================ ===========================
>>playlist.php
>>================================================ ===========================
>><?php
>>
>>$fileName = "./test.m3u";
>>$fp = fopen($fileName,"r");
>>$contents = fread($fp,filesize($fileName));
>>
>>header("Content-Type: audio/mpegurl");
>>header("Content-Disposition: filename=playlist.m3u");
>>
>>echo $contents;
>>
>>?>
>>================================================ ===========================
>>
>>Regards,
>>
>>- Dan
>>http://blog.dantripp.com/[/color]
>
>
> Thanks for your help!
>
>
> I have now solved the problem:
>
> Before I tried to send the headers I started a session with:
> session_start();
>
> ...when I removed this line, everything worked perfect!
>
> /E[/color]

Awesome! I've done something akin to that a time or two myself. =)

Regards,

- Dan
Closed Thread