gpt4 book ai didi

javascript - 网络音频 API,事件?

转载 作者:可可西里 更新时间:2023-11-01 02:20:34 25 4
gpt4 key购买 nike

是否可以将事件监听器添加到网络音频 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com