[英]Playlist and Jplayer, can't play one songs after the other
I cannot get Jplayer to play one song after the other when I use a button to play the first one. 当我使用按钮播放第一首歌时,我无法让Jplayer播放另一首歌。 When I hardcode the variable
refid
eg. 当我硬编码变量
refid
例如。 myPlaylist.select(3);
it works perfectly. 它完美地工作。 But when I get the value from the html/php part it doesn't work, it plays the current song and then it stops.
但是,当我从html / php部分获取值时,它不起作用,它将播放当前歌曲,然后停止播放。
Thank you in advance for your help. 预先感谢您的帮助。
And here is the php/html 这是php / html
echo'<td> <a href="" value="'.$songid.'" class="playitem1"> '. ucfirst($results['song_name']).' </td>';
And here is the javascipt : 这是javascipt:
$(document).ready(function(){
$(".playitem1").click(function(event){
event.preventDefault();
playthis($(this).attr("value"));
})
function playthis(refid){
myPlaylist.pause();
myPlaylist.select(refid);
myPlaylist.play();
}
var myPlaylist = new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_1",
cssSelectorAncestor: "#jp_container_1"
}, [{
title:"Cro Magnon Man",
artist:"The Stark Palace",
mp3:"http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3",
oga:"http://www.jplayer.org/audio/ogg/TSP-01-Cro_magnon_man.ogg",
poster: "http://www.jplayer.org/audio/poster/The_Stark_Palace_640x360.png"
},
{
title:"Your Face",
artist:"The Stark Palace",
mp3:"http://www.jplayer.org/audio/mp3/TSP-05-Your_face.mp3",
oga:"http://www.jplayer.org/audio/ogg/TSP-05-Your_face.ogg",
poster: "http://www.jplayer.org/audio/poster/The_Stark_Palace_640x360.png"
},
]);
});
For those who are interested I found the answer. 对于那些有兴趣的人,我找到了答案。 The
$songid
issued by the php is a string and not an integer, so I had to add parseInt();
php发出的
$songid
是一个字符串,而不是整数,因此我必须添加parseInt();
$songid
to my javascript. 我的JavaScript。 The javascript looks like that now :
javascript现在看起来像这样:
function playthis(refid){
refid = parseInt(refid);
myPlaylist.select(refid);
myPlaylist.play();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.