实际上在我的网站www.musicking.in当用户选择歌曲时,将打开一个播放器窗口并将访问相应的所选歌曲xml播放列表,播放器将播放这些歌曲。
实际上它的工作正常。但有时候问题是当有这么多用户正在播放没有播放所选歌曲的播放器时,无论是之前他选择的歌曲还是什么都不播放。
<?php
if(isset($_POST["song"])&& $_POST['song'] != "")
{
$song = $_POST["song"];
}
else {$song=array();}
$dom = new DOMDocument("1.0");
// display document in browser as plain text
// for readability purposes
// create root element
$root = $dom->createElement("playlist");
$dom->appendChild($root);
$root->setAttribute('version', "1");
$root->setAttribute('xmlns', "http://xspf.org/ns/0/");
$rootnext = $dom->createElement("trackList");
$root->appendChild($rootnext);
foreach ($song as $counter) {
$tokens = ",";
$tokenized = strtok($counter, $tokens);
// create child element
$song = $dom->createElement("track");
$rootnext->appendChild($song);
$song1 = $dom->createElement("creator");
$song->appendChild($song1);
$text = $dom->createTextNode("www.musicking.in");
$song1->appendChild($text);
$song1 = $dom->createElement("title");
$song->appendChild($song1);
// create text node
$text = $dom->createTextNode($tokenized);
$song1->appendChild($text);
$tokenized = strtok($tokens);
$song1 = $dom->createElement("location");
$song->appendChild($song1);
$text = $dom->createTextNode($tokenized);
$song1->appendChild($text);
}
// save
$dom->save("playlist.xml");
?>
<object data="musicplayer.swf?autostart=true&playlist=playlist.xml" type="application/x-shockwave-flash" width="400" height="300"><param name="movie" value="musicplayer.swf?autostart=true&playlist=playlist.xml"/></object>
<?xml version="1.0"?>
<playlist xmlns="http://xspf.org/ns/0/" version="1"><trackList><track><creator>www.musicking.in</creator><title>Ey Yavo </title><location>/telugusongs/prayanam/Ey Yavo.mp3</location></track><track><creator>www.musicking.in</creator><title>Meghamaa </title><location>/telugusongs/prayanam/Meghamaa.mp3</location></track><track><creator>www.musicking.in</creator><title>Nuvvu Entha </title><location>/telugusongs/prayanam/Nuvvu Entha.mp3</location></track></trackList></playlist>
我尝试了以下代码,但没有工作
if(isset($_POST["song"])&& $_POST['song'] != "")
{
$song = $_POST["song"];
}
else {$song=array();}
<object data="musicplayer.swf?autostart=true&playlist=playlist.php?song=<?=$song; ?>" type="application/x-shockwave-flash" width="400" height="300"><param name="movie" value="musicplayer.swf?autostart=true&playlist=playlist.php?song=<?=$song; ?>"/></object>
<?php
if(isset($_POST["song"])&& $_POST['song'] != "")
{
$song = $_POST["song"];
}
else {$song=array();}
$dom = new DOMDocument("1.0");
// display document in browser as plain text
// for readability purposes
// create root element
$root = $dom->createElement("playlist");
$dom->appendChild($root);
$root->setAttribute('version', "1");
$root->setAttribute('xmlns', "http://xspf.org/ns/0/");
$rootnext = $dom->createElement("trackList");
$root->appendChild($rootnext);
foreach ($song as $counter) {
$tokens = ",";
$tokenized = strtok($counter, $tokens);
// create child element
$song = $dom->createElement("track");
$rootnext->appendChild($song);
$song1 = $dom->createElement("creator");
$song->appendChild($song1);
$text = $dom->createTextNode("www.musicking.in");
$song1->appendChild($text);
$song1 = $dom->createElement("title");
$song->appendChild($song1);
// create text node
$text = $dom->createTextNode($tokenized);
$song1->appendChild($text);
$tokenized = strtok($tokens);
$song1 = $dom->createElement("location");
$song->appendChild($song1);
$text = $dom->createTextNode($tokenized);
$song1->appendChild($text);
}
// save
echo $dom->saveXML();
?>
<object data="musicplayer.swf?autostart=true&playlist=playlist.xml" type="application/x-shockwave-flash" width="400" height="300"><param name="movie" value="musicplayer.swf?autostart=true&playlist=playlist.xml"/></object>
答案 0 :(得分:2)
我认为您遇到的问题是多个用户共享相同的.xml文件。
您可以通过以下方法之一轻松解决这个问题:
对于第一个你将你的嵌入改为这样的东西:
musicplayer.swf?autostart=true&playlist=playlist.php
然后playlist.php看起来像这样:
<?php
session_start();
header('Content-type: text/xml');
print($_SESSION['xml']);
?>
答案 1 :(得分:1)