dan
dan

Reputation: 1402

(Audio) captureStream is not a function in Safari

I'm trying to get the CaptureStream of an HTML audio element.

  const sUsrAg = navigator.userAgent;
  var playBackStream = null

  if (sUsrAg.indexOf("Firefox") > -1) {
    console.log("Firefox");
    playBackStream = this.$refs.localaudio.mozCaptureStream();
  }
  else {
    console.log("Other");
    playBackStream = this.$refs.localaudio.captureStream();
  }

I'm using Nuxt, so that's where the $refs come from. Basically referring to something like this:

<audio
  id="localaudio"
  ref="localaudio"
  ...
></audio>

While this does work in Chrome and Firefox, it doesn't work in Safari.

TypeError: this.$refs.localaudio.captureStream is not a function. (In ‘this.$refs.localaudio.captureStream()’, ‘this.$refs.localaudio.captureStream’ is undefined)

I read somewhere about a Safari solution like this:

this.$refs.localaudio.captureStream = () => playBackStream

But that gives me:

Unhandled Promise Rejection: TypeError: S.stop is not a function. (In ‘S.stop()’, ‘S.stop’ is undefined)

Upvotes: 2

Views: 553

Answers (0)

Related Questions