是否可以将事件监听器添加到网络音频 api 声音?我一直在寻找声音完成但找不到任何东西时的事件或触发器。这是我想象的工作方式:

soundSource = context.createBufferSource();
soundBuffer = context.createBuffer(audioData, true);
soundSource.buffer = soundBuffer;
soundSource.connect(volumeNode);
soundSource.addEventListener('ended', function(e){
    console.log("ended", "", e);
}, false);
soundSource.noteOn(context.currentTime);

最佳答案

var isFinished = false;
var source = context.createBufferSource();
source.onended = onEnded;
function onEnded() {
    isFinished = true;
    console.log('playback finished');
}

Check this out

关于javascript - 网络音频 API,事件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13617047/

10-12 15:15