async function selectSource(source) {

  videoSelectBtn.innerText = source.name;

  let constraints = {
    audio: false,
    video: {
      mandatory: {
        chromeMediaSource: 'desktop',
        chromeMediaSourceId: source.id,
        minWidth: 430,
        maxWidth: 430,
        minHeight: 240,
        maxHeight: 240
      }
    }
  };

  // Create a Stream
  const stream = await navigator.mediaDevices
    .getUserMedia(constraints);

  // Preview the source in a video element
  videoElement.srcObject = stream;
  videoElement.play();

  // Create the Media Recorder
  const options = { mimeType: 'video/webm; codecs=vp9' };
  mediaRecorder = new MediaRecorder(stream, options);

  // Register Event Handlers
  mediaRecorder.ondataavailable = handleDataAvailable;
  mediaRecorder.onstop = handleStop;

  // Updates the UI
}
// Change the videoSource window to record
Change the videoSource window to record
Change the videoSource window to record
async function selectSource(source) {
  videoSelectBtn.innerText = source.name;
  let constraints = {
    audio: false,
    video: {
      mandatory: {
        chromeMediaSource: 'desktop',
        chromeMediaSourceId: source.id,
        minWidth: 430,
        maxWidth: 430,
        minHeight: 240,
        maxHeight: 240
      }
    }
  };
  const stream = await navigator.mediaDevices
    .getUserMedia(constraints);
  videoElement.srcObject = stream;
  videoElement.play();
  const options = { mimeType: 'video/webm; codecs=vp9' };
  mediaRecorder = new MediaRecorder(stream, options);
  mediaRecorder.ondataavailable = handleDataAvailable;
  mediaRecorder.onstop = handleStop;
}
async function selectSource ( source ) { videoSelectBtn . innerText = source . name ; let constraints = { audio : false , video : { mandatory : { chromeMediaSource : 'desktop' , chromeMediaSourceId : source . id , minWidth : 430 , maxWidth : 430 , minHeight : 240 , maxHeight : 240 } } } ; const stream = await navigator . mediaDevices . getUserMedia ( constraints ) ; videoElement . srcObject = stream ; videoElement . play ( ) ; const options = { mimeType : 'video/webm; codecs=vp9' } ; mediaRecorder = new MediaRecorder ( stream , options ) ; mediaRecorder . ondataavailable = handleDataAvailable ; mediaRecorder . onstop = handleStop ; }
Change the videoSource window to record
Change the videoSource window to record
// Create a Stream // Preview the source in a video element // Create the Media Recorder // Register Event Handlers // Updates the UI