Below is the code for my player which will automatically generate a playlist.xml file according to the songs selected by the user. I kept this file as player.php in my root folder, and in the form I give:
<form method='post' action='/player.php' target='_blank'>
so this player is opening and playing songs according to what is selected.
But the problem is when the user again selects different songs while previously selected songs are playing in the player in new window, the new songs selected are opening in one more window, i.e. now two player windows are opened.
Actually, I want the second selected songs will play in the same window which is already opened. You can check what’s happening in my site by playing songs: http://www.musicking.in/hindi-songs/69.html
<html> <body> <?php if(isset($_POST['song'])&& $_POST['song'] != '') { $song = $_POST['song']; } else { $song=array(); } for ($i='0'; $i<count($song); $i++) { //echo $song[$i]; } //start of new php codep // create doctype //$array = array( // 'song.mp3','song.mp3','song.mp3', //); $dom = new DOMDocument('1.0'); // display document in browser as plain text // for readability purposes header('Content-Type: text/plain'); // create root element $root = $dom->createElement('xml'); $dom->appendChild($root); $i = '1'; foreach ($song as $counter) { // create child element $song = $dom->createElement('track'); $root->appendChild($song); $song1 = $dom->createElement('path'); $song->appendChild($song1); // create text node $text = $dom->createTextNode($counter); $song1->appendChild($text); $song1 = $dom->createElement('title'); $song->appendChild($song1); $text = $dom->createTextNode('song '.$i); $song1->appendChild($text); $i++; } // save and display tree //echo $dom->saveXML(); $dom->save('playlist.xml'); ?> <script type='text/javascript' src='swfobject.js'></script> <div id='flashPlayer'> This text will be replaced by the flash music player. </div> <script type='text/javascript'> var so = new SWFObject('playerMultipleList.swf', 'mymovie', '295', '200', '7', '#FFFFFF'); so.addVariable('autoPlay','yes') so.addVariable('playlistPath','playlist.xml') so.write('flashPlayer'); </script> </body> </html>
you can only do this with javascript as far as i know … and theres a small hack to detect if a pop-up was opened and if it did to send javascript requests to it.