📝 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:
Mathieu Débit 2017-08-18 21:32:03 +02:00
parent ac6a44f0ac
commit 81f7b422e4

View file

@ -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) {