Failed to construct 'AudioContext': number of hardware contexts reached maximum

后端 未结 5 1766
名媛妹妹
名媛妹妹 2021-02-07 03:49

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++) {
            


        
5条回答
  •  后悔当初
    2021-02-07 04:12

    I was working on a media player widget which broke on Chrome (but not Firefox) as soon as more than five were embedded in a single page.

    I discovered that you can create a single AudioContext and store it globally, then have each instance just use the shared AudioContext. It seems to work no differently - you can attach multiple buffers and multiple destinations and the audio all gets mixed together.

    This might require more effort if you're using it for timing, but for playback of one or more audio streams generated on-the-fly with JS code, sharing a single AudioContext works fine.

提交回复
热议问题