2009-02-23 45 views
0

下面是我的播放器的代碼,它會根據用戶選擇的歌曲自動生成一個playlist.xml文件。我一直在這個文件player.php在我的根文件夾,並在窗體我給:根據選定的內容如何讓我的PHP應用程序重新使用相同的窗口播放音樂?

<form method="post" action="/player.php" target="_blank"> 

所以這個播放器打開並播放歌曲。

但問題在於當用戶在新窗口中播放先前選擇的歌曲時,用戶再次選擇不同的歌曲時,所選擇的新歌曲在另一個窗口中打開,即現在打開兩個播放器窗口。

實際上,我希望第二個選定的歌曲將在已打開的同一個窗口中播放。您可以檢查什麼的被播放的歌曲在我的網站上發生的事情: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> 
+0

您的代碼格式被破壞,有些部分甚至似乎丟失:( – Karsten 2009-02-23 07:51:06

回答

1

你只能用JavaScript這樣做,因爲據我所知。 ..和theres小黑客檢測是否彈出窗口被打開,如果它確實發送JavaScript請求。

0

我知道這可能不是「修復」你正在尋找,但儘量指定目標在你的Flash變量。

我認爲這可能有助於指定_self

只是一個想法

0

試試這個關於大小;)

<form method="post" action="/player.php" target="popup-player" target="playerTargetWin" onSubmit="window.open('about:blank','playerTargetWin','width=300,height=300')"> 
    <p> 
     <label for="textfield">Type something in the box:</label> 
     <input type="text" name="textfield" id="textfield" /> 
    </p> 
    <p> 
     <input type="submit" value="Submit" /> 
    </p> 
</form> 
相關問題