我实际上正在研究这个提到的标题。播放器显示列表,其生成完美。但我无法让它真正播放该文件。我一定是在哪里错了。我需要建议狐狸。(啊,如果我可以附上文件。)
my class
class DecodDir
{
function getFiles($directory)
{
$all_files = array();
$handler = opendir($directory);
while($files=readdir($handler))
{
if($files!="." && $files!="..")
{
$all_files[]= $files;
}
}
closedir($handler);
return $all_files;
}
}
################# file where i am using this class *###############
<?php
include("decoddir.php");
$obj = new DecodDir();
$results = $obj->getFiles("mp3");
$total = count($results);
$string = "";
for($i=0; $i<$total; $i++){
$string .="
{
name:'$results[$i]',
mp3:'mp3/$results[$i]',
ogg:'$results[$i]'
},
";
}
?>
// its at the top of that html file (ofcorse with the php ext)
and below, this is where it is generating the playlist
var audioPlaylist = new Playlist("2", [
<?php echo $string; ?>
],
http://www.jplayer.org/latest/demo-02/(我从那里获得 jplayer 的链接)你可以看到带有播放列表的音频播放器。(实际上我不知道这里stackoverflow中的代码的热格式)谢谢Rafay