Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions src/components/MediaDevicesPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,28 @@ export default {

this.pendingGetUserMediaAudioCount = 1

const resetPendingGetUserMediaAudioCount = () => {
const updateAudioStreamAgain = this.pendingGetUserMediaAudioCount > 1

this.pendingGetUserMediaAudioCount = 0

if (updateAudioStreamAgain) {
this.updateAudioStream()
}
}

this.mediaDevicesManager.getUserMedia({ audio: true })
.then(stream => {
this.setAudioStream(stream)

resetPendingGetUserMediaAudioCount()
})
.catch(error => {
console.error('Error getting audio stream: ' + error.name + ': ' + error.message)
this.audioStreamError = error
this.setAudioStream(null)
}).finally(() => {
const updateAudioStreamAgain = this.pendingGetUserMediaAudioCount > 1

this.pendingGetUserMediaAudioCount = 0

if (updateAudioStreamAgain) {
this.updateAudioStream()
}
resetPendingGetUserMediaAudioCount()
})
},

Expand Down Expand Up @@ -386,22 +392,28 @@ export default {

this.pendingGetUserMediaVideoCount = 1

const resetPendingGetUserMediaVideoCount = () => {
const updateVideoStreamAgain = this.pendingGetUserMediaVideoCount > 1

this.pendingGetUserMediaVideoCount = 0

if (updateVideoStreamAgain) {
this.updateVideoStream()
}
}

this.mediaDevicesManager.getUserMedia({ video: true })
.then(stream => {
this.setVideoStream(stream)

resetPendingGetUserMediaVideoCount()
})
.catch(error => {
console.error('Error getting video stream: ' + error.name + ': ' + error.message)
this.videoStreamError = error
this.setVideoStream(null)
}).finally(() => {
const updateVideoStreamAgain = this.pendingGetUserMediaVideoCount > 1

this.pendingGetUserMediaVideoCount = 0

if (updateVideoStreamAgain) {
this.updateVideoStream()
}
resetPendingGetUserMediaVideoCount()
})
},

Expand Down
3 changes: 3 additions & 0 deletions src/utils/webrtc/MediaDevicesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ MediaDevicesManager.prototype = {
* constraints do not specify a device already. Otherwise the devices in the
* constraints are respected.
*
* For compatibility with older browsers "finally" should not be used on the
* returned Promise.
*
* @param {MediaStreamConstraints} constraints the constraints specifying
* the media to request
* @returns {Promise} resolved with a MediaStream object when successful, or
Expand Down