mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
📝 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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user