diff --git a/src/content/getusermedia/record/css/main.css b/src/content/getusermedia/record/css/main.css index 6abc518e50..a56fc754a5 100644 --- a/src/content/getusermedia/record/css/main.css +++ b/src/content/getusermedia/record/css/main.css @@ -9,7 +9,7 @@ margin: 0 3px 10px 0; padding-left: 2px; padding-right: 2px; - width: 99px; + width: 120px; } button:last-of-type { diff --git a/src/content/getusermedia/record/index.html b/src/content/getusermedia/record/index.html index 774840760a..14af94cbf7 100644 --- a/src/content/getusermedia/record/index.html +++ b/src/content/getusermedia/record/index.html @@ -44,7 +44,8 @@

WebRTC
- + + diff --git a/src/content/getusermedia/record/js/main.js b/src/content/getusermedia/record/js/main.js index d8089fb33b..a9e2a664ce 100644 --- a/src/content/getusermedia/record/js/main.js +++ b/src/content/getusermedia/record/js/main.js @@ -144,7 +144,7 @@ function stopRecording() { function handleSuccess(stream) { recordButton.disabled = false; - console.log('getUserMedia() got stream:', stream); + console.log('Got stream:', stream); window.stream = stream; const gumVideo = document.querySelector('video#gum'); @@ -159,27 +159,37 @@ function handleSuccess(stream) { codecPreferences.disabled = false; } -async function init(constraints) { +async function init(constraints, isGetDisplayMedia) { try { - const stream = await navigator.mediaDevices.getUserMedia(constraints); + const stream = isGetDisplayMedia ? + await navigator.mediaDevices.getDisplayMedia(constraints) : + await navigator.mediaDevices.getUserMedia(constraints); handleSuccess(stream); } catch (e) { - console.error('navigator.getUserMedia error:', e); - errorMsgElement.innerHTML = `navigator.getUserMedia error:${e.toString()}`; + console.error('Source open error:', e); + errorMsgElement.innerHTML = `Source error: ${e.toString()}`; } } -document.querySelector('button#start').addEventListener('click', async () => { - document.querySelector('button#start').disabled = true; +async function onStart(isGetDisplayMedia) { + document.querySelector('button#start-gum').disabled = true; + document.querySelector('button#start-gdm').disabled = true; const hasEchoCancellation = document.querySelector('#echoCancellation').checked; const constraints = { audio: { - echoCancellation: {exact: hasEchoCancellation} + echoCancellation: hasEchoCancellation }, video: { width: 1280, height: 720 } }; console.log('Using media constraints:', constraints); - await init(constraints); + await init(constraints, isGetDisplayMedia); +} + +document.querySelector('button#start-gum').addEventListener('click', async () => { + await onStart(false); +}); +document.querySelector('button#start-gdm').addEventListener('click', async () => { + await onStart(true); });