📝 Fix desktopCapturer example (#10303)
[ci skip] Based on MDN example: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Examples
This commit is contained in:
parent
ac6a44f0ac
commit
81f7b422e4
1 changed files with 6 additions and 2 deletions
|
@ -28,14 +28,18 @@ desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
|
|||
maxHeight: 720
|
||||
}
|
||||
}
|
||||
}, handleStream, handleError)
|
||||
})
|
||||
.then((stream) => handleStream(stream))
|
||||
.catch((e) => handleError(e))
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function handleStream (stream) {
|
||||
document.querySelector('video').src = URL.createObjectURL(stream)
|
||||
const video = document.querySelector('video')
|
||||
video.srcObject = stream
|
||||
video.onloadedmetadata = (e) => video.play()
|
||||
}
|
||||
|
||||
function handleError (e) {
|
||||
|
|
Loading…
Reference in a new issue