如何在开始时播放播放列表中的单个曲目编号?
How to play individual track number from playlist at start?
我正在使用 jPlayer plugin. Here is an example link [ jsfiddle ]。我只想从单个曲目编号开始播放列表,我的意思是如果播放列表中有 5/10 首曲目,那么我想从 2/5 曲目编号开始播放列表。
您需要稍微修改 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);
}
我正在使用 jPlayer plugin. Here is an example link [ jsfiddle ]。我只想从单个曲目编号开始播放列表,我的意思是如果播放列表中有 5/10 首曲目,那么我想从 2/5 曲目编号开始播放列表。
您需要稍微修改 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);
}