javascript - 如何清除/释放音频接触 html5

标签 javascript html html5-audio

有没有办法清除/释放/删除 html5 中的音频上下文?

我已经完成了以下教程,但找不到任何内容。

Tutorial

最佳答案

youraudiocontext.close();

够简单吗?

关闭后,可以使用then()方法进行基本重置:

youraudiocontext.close().then(function() {
    // set things here //
});

The close() method of the AudioContext Interface closes the audio context, releasing any system audio resources that it uses.

Closed contexts cannot have new nodes created, but can decode audio data, create buffers, etc.

This function does not automatically release all AudioContext-created objects, unless other references have been released as well; however, it will forcibly release any system audio resources that might prevent additional AudioContexts from being created and used, suspend the progression of audio time in the audio context, and stop processing audio data. The returned Promise resolves when all AudioContext-creation-blocking resources have been released. This method throws an INVALID_STATE_ERR exception if called on an OfflineAudioContext.

关于javascript - 如何清除/释放音频接触 html5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32142641/

相关文章:

javascript - 允许 audio.play() 在 safari 上用于聊天应用程序

javascript - 我正在构建一个答题器游戏,本地存储没有返回任何内容,而是返回了保存的数据

javascript - 带流的 JS 文件 uploader ,即不将整个文件加载到内存中

javascript - 在切换 asp.net 时更改 jquery 中的文本

html - 将鼠标悬停在类上时更改 li 类的 CSS

javascript - 剑道网格 : how add colorpicker

audio - 在我的 Windows 应用商店 HTML5 应用中启用背景音频

javascript - jQuery 多个 AJAX 同步请求&动态添加 html 和事件

javascript - 如何在 AMP html 网站中获取 Medium 博客文章?

javascript - <audio> 的正确加载