我有一个使用 soundmanager 2 播放音乐的功能,当我按下按钮加载下一个声音时,该功能有效,但是当我尝试通过该onfinish
功能执行此操作时,它不起作用,这意味着当音乐播放完毕时它不起作用t 加载下一个声音我怎样才能让它工作,请参阅下面的代码。
function playSong(id) {
//Stop the sound from playing
soundManager.destroySound(mySound);
//If we're under, just go to the end!
if (id < 0)
id = songs.length - 1;
//If we're over, choose what to do via the repeat flag
if (id >= songs.length)
id = 0;
//Save some variables
playingSongId = id;
playingSong = songs[playingSongId];
track = playingSong.artist_name + " " + "-" + " " + playingSong.track_name;
//Create the sound and begin playing whenever!
soundManager.createSound({
id: mySound,
url: playingSong.track_url,
multiShotEvents: true,
autoPlay: true,
stream: true,
onplay: function () {
setPlayingInfo(track);
setPauseState(false);
setPlayTime();
},
onfinish: function() {
playNextSong();
/*//We'll only continue if we're shuffling or repeating if we past the end...
if (shuffle == false && (playingSongId + 1 >= songs.length) && repeat == false) {
//No more songs...
setPlayingInfo();
setPauseState(false);
setPlayTime();
playingSong = null;
playingSongId = null;
return;
}
else {
playNextSong();
}*/
},
当下一个声音的标题出现在标题中时,该功能起作用,但歌曲从不播放。最后,当我在声音加载和播放时单击第一个声音链接时,不会加载标题,但是如果我单击按钮加载下一个声音,则会出现标题。请注意,我通过 ajax 加载这些声音,因为这些声音位于远程服务器上。