How can I queue a series of sound HTML5 <audio> sound clips to play in sequence?

后端 未结 4 2048
长情又很酷
长情又很酷 2020-12-18 04:19

I\'m experimenting with porting a simple audio utility called VoiceWalker to Javascript. VoiceWalker is a tool to help people transcribe audio, and it works like this:

4条回答
  •  鱼传尺愫
    2020-12-18 04:33

    Make clip call itself:

    function clip(audio, start, stop){
        audio.currentTime = start;
        audio.play();
        int = setInterval(function() {
            if (audio.currentTime > stop) {
                audio.pause();
                clearInterval(int);
                // Play it again, 2 seconds further.
                clip(audio, start + 2, stop + 2);
            }
        }, 10);
    }
    

提交回复
热议问题