本文介绍了无法构造'AudioContext':硬件上下文的数量达到最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在我创建后删除 AudioContext

Is there a way to remove an AudioContext after I've created it?

var analyzers = [];
var contexts = [];

try {
   for(var i = 0; i<20; i++) {
      contexts[i] = new AudioContext();
      analyzers[i] = contexts[i].createAnalyser();
   }
}catch(e) {
   console.log(e);
   // too many contexts created -- how do I remove them?
}

我试过这个,但它不会让我创建新的上下文之后: analyzers.forEach(function(analyzer){analyzer.disconnect(analyzer.context.destination)})

I've tried this, but it doesn't let me create new contexts after the fact: analyzers.forEach(function(analyzer){analyzer.disconnect(analyzer.context.destination)})

我在Ubuntu Linux 14.04上使用Chrome 36。

I am using Chrome 36 on Ubuntu Linux 14.04.

推荐答案

你应该只有一个页面中的AudioContext

来自文档:在大多数用例中,每个文档只使用一个AudioContext。

From the docs: "In most use cases, only a single AudioContext is used per document."

我无法想到你曾经需要不止一个的原因。是否存在导致您创建多个上下文的特定问题?

I can't really think of a reason why you'd ever need more than one. Is there a specific issue you've run into that caused you to create multiple contexts?

这篇关于无法构造'AudioContext':硬件上下文的数量达到最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 17:35