html - 在 HTML5/Chrome 中获取 AudioBuffer 的 onended 事件

标签 html google-chrome web-audio-api

所以我在 Chrome 中播放音频文件,我想检测播放何时结束,以便删除对它的引用。这是我的代码

var source = context.createBufferSource();
source.buffer = sound.buffer;
source.loop = sound.loop;
source.onended = function() { 
    delete playingSounds[soundName];
}
source.connect(mainNode);
source.start(0, sound.start, sound.length);

但是,事件处理程序不会触发。这是否还不支持,如 W3 specification 所述?还是我做错了什么?

最佳答案

Chromium 最近才添加了这个(我想是五月底)。很确定它还没有在稳定版本中。

您在 Chrome Canary 中尝试过吗?

关于html - 在 HTML5/Chrome 中获取 AudioBuffer 的 onended 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17345359/

相关文章:

android - Facebook Messenger 发送元数据 (Android)

html - 如果图像加载失败,我可以在 alt 属性中显示图像吗

javascript - 现在缺少 g 标志时 matchAll 抛出错误?

html - CSS3 动画中的 left 与 translateX

google-chrome - Vb 脚本不适用于 Chrome 或 Firefox - 仅适用于 Internet Explorer

html - 音频输出2台设备

html - 汉堡导航栏不适用于固定位置

javascript - 如何在没有正确用户 ID 的情况下嵌入 YouTube 的所有 channel 视频

web-audio-api - 如何使用网络音频 API 设置采样率?

audio - Web Audio API如何影响游戏开发?