jeudi 11 avril 2019

Why it taking too long to resolve getUserMedia in Firefox, even after stopping all MediaStreamTrack?

I have a drop-down to select different media devices for recording audio and video.

While changing the device in Firefox, I'm stopping all the active mediaStreamTrack then again catching the stream with the selected device. But its taking too much time to resolved. Its working fine in Google Chrome.

_clearStream() {
    if(this.get('mediaStream')) {
      this.get('mediaStream').getAudioTracks().forEach(track => track.stop())
      this.get('mediaStream').getVideoTracks().forEach(track => track.stop())
    }
    if(this.get('audio.mediaStream')) {
      this.get('audio.mediaStream').getAudioTracks().forEach(track => track.stop())
      this.get('audio.mediaStream').getVideoTracks().forEach(track => track.stop())
    }
    this._getStream()
  },

  _getStream() {
    const constraints = {
      audio: { deviceId: this.get('audioSourceDevice') ? { exact: this.get('audioSourceDevice.deviceId')} : undefined },
      video: { width: 320, height: 240, deviceId: this.get('videoSourceDevice') ? { exact: this.get('videoSourceDevice.deviceId')} : undefined }
    }
    return navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
      this.set('mediaStream', stream)
      this.set('audio.mediaStream', stream)
      return stream
    })
  }




Aucun commentaire:

Enregistrer un commentaire