Using AudioContext in multiple iframes

We have a blog, each post of which contains an iframe , which, in turn, should play sound using Web Audio when you click Play.

The problem is that after a certain number of messages on the page, the next frame causes an error: Uncaught SyntaxError: Failed to construct 'AudioContext': number of hardware contexts reached maximum (6).

It is not possible to reuse the same audio window.top between frames - window.top is verboten due to policies of the same origin.

Here is a simplified example: http://jsfiddle.net/aobpv7kg/ (click Add frame until you get an error - the 7th frame in my case).

Can an arbitrary number of frames per page use web audio? Or the number of posts per page is reduced to 5, what can we do?

+5
source share
1 answer

Now all that you can do. (Or use postMessage to communicate across window borders, doing all the real work of audio in a single window.) We address this issue in both Chrome and the spec.

+8
source

Source: https://habr.com/ru/post/1203145/


All Articles