嚎叫不会在onend后立即开始

Howl doesn't start immediately after onend

我正在用纯 HTML5JavaScript 制作视频游戏,我遇到了一个错误,它在 onend 之后等待另一首歌曲 0 到 5 秒玩。我正在尝试在歌曲中间添加一个循环,该循环会一直重复直到某件事发生。除了延迟之外,我已经完成了大部分工作。这是我的代码。 (简体)

function playMusic(source) {
    if(soundOn) {
        music = new Howl({
            src: [source],
            autoplay: true,
            loop: true,
            volume: (musicVol / 100),
            onend: function() {
                songEnded = 1;
                setTimeout(function() {songEnded = 0;}, 1000)
            }
        });
    }
}
function quickMusic() {
    if(soundOn) {
        music = new Howl({
            src: ['song_start.wav'],
            autoplay: true,
            loop: false,
            volume: (musicVol / 100),
            onend: function() {
                console.log("Finished!") //For debugging
                playMusic('song_loop.wav')
            }
        });
    }
}

我找到了一种方法,很抱歉回答我自己的问题,但我是这样做的。

function quickMusic() {
    if(soundOn) {
        music1 = new Howl({
            src: ['song_loop.wav'],
            autoplay: false,
            loop: true,
            volume: (musicVol / 100),
            onend: function() {
                console.log("Finished!") //For debugging
            }
        });
        music = new Howl({
            src: ['song_start.wav'],
            autoplay: true,
            loop: false,
            volume: (musicVol / 100),
            onend: function() {
                console.log("Finished!") //For debugging
                TEMP = music1
                music1 = music
                music = TEMP //I had to add this because of a volume slider
                music.play()
            }
        });
    }
}