Codeschnipsel - PLS Plugin for Flash MP3 Player
English:
I have written a Plugin for the Flash MP3 Player / JW Media Player from Jeroenwijering.
It generates a XML-Playlist from a .pls file.
For m3u Files, click here....
Required is a PLS File.
You must configure the playlists:
$playlist = array(
'1' => 'http://domain.tld/folder/playlist.pls',
'2' => 'list.pls',
'3' => 'list3.pls',
'4' => 'list4.pls'
// And so on....
// 'NUMBER' => 'path/url',
);
Instead of the playlist.xml you must insert "plsplugin.php?pls=1" the number 1 is for the PLS file number 1
Example Version 3.5:
Code:<script type="text/javascript"> var FU = { movie:"mp3player.swf",width:"240",height:"135",majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file=plsplugin.php?pls=1&lightcolor=0xCC0066&backcolor=0x000000 &frontcolor=0xFFFFFF&displayheight=0" }; UFO.create(FU,"player2"); </script>
Example Version 3.8:
Code:<p id="player2"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p> <script type="text/javascript"> var s2 = new SWFObject("mp3player.swf", "playlist", "240", "135", "7"); s2.addVariable("file","plsplugin.php?pls=1"); s2.addVariable("backcolor","0x00000"); s2.addVariable("frontcolor","0xEECCDD"); s2.addVariable("lightcolor","0xCC0066"); s2.addVariable("displayheight","0"); s2.write("player2"); </script>
Example JW FLV MEDIA PLAYER 3.15
With "embed"-Tag:
Code:<embed src="mediaplayer.swf" width="400" height="134" allowscriptaccess="always" allowfullscreen="true" flashvars="height=134&width=400&file=plsplugin.php?pls=1&displaywidth=0&showstop=true&autoscroll=true&thumbsinplaylist=false" />
With Javascript:
Code:<div id="container"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div> <script type="text/javascript" src="swfobject.js"></script> <script type="text/javascript"> var s1 = new SWFObject("mediaplayer.swf","mediaplayer","300","170","7"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addVariable("width","300"); s1.addVariable("height","120"); s1.addVariable("displaywidth","0"); s1.addVariable("thumbsinplaylist","false"); s1.addVariable("showstop","true"); s1.addVariable("file","plsplugin.php?pls=1"); s1.write("container"); </script>
If you have problems with a charset, please contact me:
MSN: heuri [at] hotmail.de
ICQ: 289021519
Mail: support [at] pa-s.de
=========================================================
German:
Ich habe ein Plugin für den MP3 von Jeroenwijering geschrieben.
Für m3u Dateien, hier klicken....
Erforderlich ist eine PLS Datei.
Sie müssen die Playlist konfigurieren:
$playlist = array(
'1' => 'http://domain.tld/ordner/playlist.pls',
'2' => 'list.pls',
'3' => 'list3.pls',
'4' => 'list4.pls'
// Und so weiter.
);
Anstelle der playlist.xml müsst ihr folgendes angeben "plsplugin.php?pls=1" Nummer 1 steht für die Playlist Nummer 1
Das Script erstellt eine XML Playliste aus der PLS Datei.
Beispiel Version 3.5:
Code:<script type="text/javascript"> var FU = { movie:"mp3player.swf",width:"240",height:"135",majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file=plsplugin.php?pls=1&lightcolor=0xCC0066&backcolor=0x000000 &frontcolor=0xFFFFFF&displayheight=0" }; UFO.create(FU,"player2"); </script>
Beispiel Version 3.8:
Code:<p id="player2"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p> <script type="text/javascript"> var s2 = new SWFObject("mp3player.swf", "playlist", "240", "135", "7"); s2.addVariable("file","plsplugin.php?pls=1"); s2.addVariable("backcolor","0x00000"); s2.addVariable("frontcolor","0xEECCDD"); s2.addVariable("lightcolor","0xCC0066"); s2.addVariable("displayheight","0"); s2.write("player2"); </script>
Beispiel JW FLV MEDIA PLAYER 3.15
Mit dem "embed"-Tag:
Code:<embed src="mediaplayer.swf" width="400" height="134" allowscriptaccess="always" allowfullscreen="true" flashvars="height=134&width=400&file=plsplugin.php?pls=1&displaywidth=0&showstop=true&autoscroll=true&thumbsinplaylist=false" />
Mit Javascript:
Code:<div id="container"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div> <script type="text/javascript" src="swfobject.js"></script> <script type="text/javascript"> var s1 = new SWFObject("mediaplayer.swf","mediaplayer","300","170","7"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addVariable("width","300"); s1.addVariable("height","120"); s1.addVariable("displaywidth","0"); s1.addVariable("thumbsinplaylist","false"); s1.addVariable("showstop","true"); s1.addVariable("file","plsplugin.php?pls=1"); s1.write("container"); </script>
=========================================================
PHP-Code (plsplugin.php):
Code:<?php ########################################################################################################################### # PLS Plugin by PA-S.de V.0.1 # (C) 2007 by http://www.PA-S.de # Needed: http://www.jeroenwijering.com/?item=Flash_MP3_Player # Plugin: http://www.pa-s.de/php/codeschnipsel-PLS-Plugin-for-Flash-MP3-Player-50.php ########################################################################################################################### // Set XML Header header('Content-type: text/xml'); // START CONFIGURE // Playlists Array // NUMBER => PATH TO FILE, MAYBE URL $playlist = array( '1' => 'test2.pls', '2' => 'http://newurl.tld/folder/playlist.pls', '3' => 'http://newurl.tld/list.pls' ); // NO CHANGE HERE // Load pls by Url $pls = trim(htmlspecialchars($_GET['pls'], ENT_QUOTES, "UTF-8")); if (is_numeric($pls)){ // Load data from Url $pls = $playlist[$pls]; $heurix = explode('/', $pls); $cpas = count($heurix); $opas = str_replace($heurix[$cpas-1], '', $pls); // Optional Umlaut converter: $upas = Array("ä" => "ae", "ü" => "ue", "ö" => "oe", "Ä" => "Ae", "Ü" => "Ue", "Ö" => "Oe"); $upasb = Array("ä" => "%E4", "Ä" => "%C4", "ö" => "%F6", "Ö" => "%D6", "ü" => "%FC", "Ü" => "%DC"); // Normal chars converter: $upasn = Array(" " => "%20"); $handle = fopen($pls, 'r') or die(); // Vars $i = 0; $cache = Array(); while (!feof($handle)) { // Load data $data = heuri(); // ADD FILE if(preg_match('/^File([0-9-]+)=(.*)/', $data, $ext2)){ if (!strpos($pls, '://')){ $cache[$i][0] = $ext2[2]; }else{ if(strpos($ext2[0], '://')){ $cache[$i][0] = $ext2[2]; }else{ $cache[$i][0] = $opas.$ext2[2]; } } $i ++; } // ADD TITLE if($cache[$i-1][0] != NULL){ if(preg_match('/^Title([0-9-]+)=(.*)/', $data, $ext)){ $cache[$i-1][1] = $ext[2]; }} } fclose($handle); // Create XML Playlist echo'<playlist version="1" xmlns="http://xspf.org/ns/0/"> <trackList>'; foreach($cache as $p => $pp){ // Optional Umlaut converter: $cache[$p][1] = strtr($cache[$p][1], $upas); $cache[$p][0] = strtr($cache[$p][0], $upasb); // Normal chars converter: $cache[$p][0] = strtr($cache[$p][0], $upasn); echo' <track> <title>'.$cache[$p][1].'</title> <location>'.$cache[$p][0].'</location> </track>'; } echo' </trackList> </playlist>'; } // Function function heuri(){ global $handle; return trim(fgets($handle, 8192)); } ?>