From 81f7b422e4d4f2835345c658492aa6869ddaaffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20D=C3=A9bit?= Date: Fri, 18 Aug 2017 21:32:03 +0200 Subject: [PATCH] :memo: Fix desktopCapturer example (#10303) [ci skip] Based on MDN example: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Examples --- docs/api/desktop-capturer.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/api/desktop-capturer.md b/docs/api/desktop-capturer.md index 5f11d94561f6..7b897f2ad1bc 100644 --- a/docs/api/desktop-capturer.md +++ b/docs/api/desktop-capturer.md @@ -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) {