2015-07-11 60 views

回答

1

您需要修改一下play()方法才能随机选择要播放的歌曲。

找到下面的代码,这是更新了自己的fiddlejs

var myPlayer = new jPlayerPlaylist(/* give your params here as you were doing */); 

// Clonning current play() method behavior 
myPlayer._play = myPlayer.play; 

// Modifying default behavior of current play() method which generates 
// a random song index if not provided 
myPlayer.play = function(songIdx){ 

    if (!songIdx) 
     songIdx = Math.floor(Math.random() * this.playlist.length); 

    this._play(songIdx); 

    console.log('Playing song #', songIdx); 
}  
+0

感谢兄弟优秀的,但我可以手动添加多个轨道? @ leo.fcx – userknowmore

+0

是的! ...看到这个更新jsfiddle(http://jsfiddle.net/leofcx/f05wxf1e/9/)...如果这是有益的,请最后的投票。 –

+0

好,然后我投票,但我想添加手动轨道号码没有Math.floor/songIdx函数请更新@ leo.fcx – userknowmore

相关问题