我正在使用jPlayer插件。这是一个示例link [ jsfiddle ]。我只想从单个曲目编号开始播放列表,我的意思是如果我在播放列表中有5/10个曲目,那么我想在开始时从2/5曲目编号开始播放列表。
答案 0 :(得分: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);
}