audiocontext - have to remove audioContext or MediaElementAudioSourceNode
问题描述
I am using an audio file received through the input type file, I also create an audio context for this file.
const audio = this.$refs.testAudio; // <audio ref="testAudio" />
this.audioContext = new (window.AudioContext || window.webkitAudioContext) ();
this.srcAudio = this.audioContext.createMediaElementSource (audio);
I need to be able to delete this file and upload a new one. for this i clear the input, stop the context and disconnect the connections
this.srcAudio.context.close (). then (() => {
this.srcAudio.disconnect ();
this.analyser = null;
this.srcAudio = null;
inputAudio.value = '';
this. $ refs.testAudio.src = null;
});
this.audioContext = null;
But any attempt to use the new file ends with an error:
Blockquote
InvalidStateError: Failed to execute 'createMediaElementSource' on 'AudioContext': HTMLMediaElement already connected previously to a different MediaElementSourceNode. "
Blockquote
help please solve the problem
解决方案
推荐阅读
- typescript - Can you do smart types in Typescript?
- php - 在 MySQL(或其他 SQL 引擎)中存储历史(影子)表的有效方法
- python - 使用 lxml python 重建 XML
- python-3.x - 树形图 - 更改字体
- scala - 如何在scala中引用自己的类?
- excel - CORREL 函数未显示结果
- c - C 宏扩展未按预期工作 - 低于错误 main.c:11:19: 错误: '(' 标记之前的预期标识符
- python-3.x - 每次启动多处理时进程消耗更多内存
- python - 将两个排序后的数组组合成一个长度相同的新数组
- android - 未能安装以下 Android SDK 软件包,因为某些许可证尚未被接受。29号平台