19c19,21 < */ --- > > > */ 24,28d25 < audio: true, < video: true < }; < < const vconstraints = window.constraints = { 33,37d29 < const aconstraints = window.constraints = { < audio: true, < video: false < }; < 39,44d30 < handleVSuccess(stream); < handleASuccess(stream); < } < < < function handleVSuccess(stream) { 47,52c33,35 < stream.onremovetrack = function() { < console.log('Stream ended'); < }; < console.log('Got video stream with constraints:', vconstraints); < console.log(`Using video device: ${videoTracks[0].label} out of ${videoTracks.length} video tracks`); < window.stream += stream; // make variable available to browser console --- > console.log('Got stream with constraints:', constraints); > console.log(`Using video device: ${videoTracks[0].label}`); > window.stream = stream; // make variable available to browser console 54,65d36 < video.play(); < } < < < function handleASuccess(stream) { < const audio = document.querySelector('audio'); < const audioTracks = stream.getAudioTracks(); < console.log('Got audio stream with constraints:', aconstraints); < console.log(`Using audio device: ${audioTracks[0].label} out of ${audioTracks.length} audio tracks`); < window.stream += stream; // make variable available to browser console < audio.srcObject = stream; < audio.play(); 93,94d63 < document.getElementById('showVideo').disabled = true; < document.getElementById('showAudio').disabled = true; 100,133c69 < async function ainit(e) { < try { < const astream = await navigator.mediaDevices.getUserMedia(aconstraints); < handleASuccess(astream); < e.target.disabled = true; < } catch (e) { < handleError(e); < } < } < < async function vinit(e) { < try { < const vstream = await navigator.mediaDevices.getUserMedia(vconstraints); < handleVSuccess(vstream); < e.target.disabled = true; < } catch (e) { < handleError(e); < } < } < < async function ainit(e) { < try { < const astream = await navigator.mediaDevices.getUserMedia(aconstraints); < handleASuccess(astream); < e.target.disabled = true; < } catch (e) { < handleError(e); < } < } < < document.querySelector('#showVideo').addEventListener('click', e => vinit(e)); < document.querySelector('#showAudio').addEventListener('click', e => ainit(e)); < document.querySelector('#showBoth').addEventListener('click', e => init(e)); < --- > document.querySelector('#showVideo').addEventListener('click', e => init(e)); \ No newline at end of file