Is there a way to know how many audio context are opened in a DOM?

Roberto Tronci Source

I'm using Web Audio API and for different reasons I have to create multiple audio context. This is not an issue with Firefox or Edge, but Chrome doesn't allow more than 6 context. Since the number of contemporary context is 3 (the others are closed using close()) probably some reference in Chrome is still counted. Is there a way to know how many Audio Contexts are associated to the DOM element?



answered 6 months ago Ben West #1

Create a wrapper function –

function createAudioContext () {
    if ( createAudioContext.count++ >= 6 ) throw new Error('uh oh')
    return new AudioContext();
createAudioContext.count = 0;

and use it in place of new AudioContext()

answered 6 months ago Raymond Toy #2

Update to a more recent version of Chrome. The limit has been removed.

comments powered by Disqus