尝试 运行 AudioContext.createMediaElementSource() 时如何修复 "Audion could not identify the object calling 'connect'" 错误?

How to fix "Audion could not identify the object calling 'connect'" error when trying to run AudioContext.createMediaElementSource()?

尝试使用 javascript 创建音频元素,然后通过调用 AudioContext.createMediaElementSource() 创建音频源,但在 Chrome 控制台中出现错误,提示 Audion 无法识别对象调用 "connect"

Screenshot of the error message

我尝试在 HTML 中创建此音频元素并使用 Document.querySelector() 获取此音频文件,但遇到了同样的错误。

const audio = new Audio("./path/to/audio.mp3");
const audioSource = audioCtx.createMediaElementSource(audio);
audioSource.connect(audioCtx.destination);

警告来自 Chrome 扩展,正式名称为 Web Audio Inspector. It's codename is Audion. The source code is available on GitHub. The warning message get's generated here: https://github.com/google/audion/blob/master/js/entry-points/tracing.js#L747

我认为问题在于 Audion 仍在修补 BaseAudioContext 的原型,但规范中最近的更改将 createMediaElementSource() 等函数移到了 AudioContext 原型。我将继续在 GitHub 上为此创建一个问题,希望在某个时候得到修复。

也就是说,这只是一个警告,不应阻止您的网站正常运行。