2015-07-11 59 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

相關問題