I'm trying to make a script that will generate a .WPL file. The script scans the folder for all .mp3 files, and includes them in the .wpl file. However it doesn't seem to work, as Windows media player gives me an error that the file is corrupted.
What is wrong with the code? :)
$ourFileName = "Playlist.wpl";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
echo "Created the playlist <br />";
$firsthalf = "
<?wpl version='1.0'?>
<smil>
<head>
<meta name='Generator' content='Microsoft Windows Media Player -- 12.0.9200.16384'/>
<meta name='IsNetworkFeed' content='0'/>
<title>Playlist</title>
</head>
<body>
<seq>";
$secondhalf = "
</seq>
</body>
</smil>
";
fwrite($ourFileHandle, $firsthalf);
foreach (glob("*.mp3") as $filename) {
fwrite($ourFileHandle, "<media src='".$filename."'/>");
}
fwrite($ourFileHandle, $secondhalf);
fclose($ourFileHandle);
EDIT: The generated .wpl file looks like this:
<?wpl version='1.0'?>
<smil>
<head>
<meta name='Generator' content='Microsoft Windows Media Player -- 12.0.9200.16384'/>
<meta name='IsNetworkFeed' content='0'/>
<title>Playlist</title>
</head>
<body>
<seq><media src='FIRST SONG.mp3'/><media src='SECOND SONG.mp3'/>
</seq>
</body>
</smil>
EDIT2: The songs are in the same folder as the playlist file. EDIT3: I'm using the newest Windows Media Player which is included in windows 8 RTM.