staskobzar / vue-audio-visual

VueJS audio visualization components
MIT License
713 stars 112 forks source link

[Bug] Failed to construct 'AudioContext' #2

Closed SohrabZ closed 6 years ago

SohrabZ commented 6 years ago

I'm receiving this error in my web page:

DOMException: Failed to construct 'AudioContext': The number of hardware contexts provided (6) is greater than or equal to the maximum bound (6).

I have multiple audio players on my website and here is my implementation:

<av-line
        :line-width="2"
        line-color="lime"
        :audio-src="scope.row.recording_url"
        ref="popover_rec_{{scope.row.id}}"
        v-if="recording_visible">
</av-line>
SohrabZ commented 6 years ago

UPDATE

I've tried to fix this by changing AvBase.js to this:

const methods = {
  ...
  setAnalyser: function () {
    const myCtx = new AudioContext()
    this.myCtx = myCtx
    const src = myCtx.createMediaElementSource(this.audio)
    this.analyser = myCtx.createAnalyser()

    src.connect(this.analyser)
    this.analyser.fftSize = this.fftSize
    this.analyser.connect(myCtx.destination)
  },
  ...
}

export default {
  ...
  beforeDestroy () {
      this.myCtx.close()
  },
  ...
}

and adding v-if to your <av-*></av-*> components

staskobzar commented 6 years ago

The fix will be available in next release. For now it will support up to 6 audio contexts as allowed by browser.