requestScreenCaptureSourceId_(
      timeoutMillis = mr.mirror.MirrorMediaStream.WINDOW_PICKER_TIMEOUT_) {
    return new Promise((resolve, reject) => {
      const desktopChooserConfig = ['screen', 'audio'];
      if (mr.PlatformUtils.getCurrentOS() == mr.PlatformUtils.OS.LINUX) {
        desktopChooserConfig.push('window');
      }
      let requestId;
      // Wait 60 seconds and then cancel the picker and reject the
      // promise.

      const timeoutId = window.setTimeout(() => {
        if (requestId) {
          chrome.desktopCapture.cancelChooseDesktopMedia(requestId);
        }
        reject(new mr.mirror.Error(
            'timeout',
            mr.MirrorAnalytics.CapturingFailure
                .CAPTURE_DESKTOP_FAIL_ERROR_TIMEOUT));
      }, timeoutMillis);
      // https://developer.chrome.com/extensions/desktopCapture#method-chooseDesktopMedia
      requestId = chrome.desktopCapture.chooseDesktopMedia(
          desktopChooserConfig, sourceId => {
            window.clearTimeout(timeoutId);
            if (!sourceId) {
              // User cancelled the desktop media selector prompt.
              reject(new mr.mirror.Error(
                  'User cancelled capture dialog',
                  mr.MirrorAnalytics.CapturingFailure
                      .CAPTURE_DESKTOP_FAIL_ERROR_USER_CANCEL));
            } else {
              resolve(sourceId);
            }
          });
    });
  }
/**
   * Requests a screen capture source from the user via a native dialog and
   * returns the source ID, or rejects if a timeout is reached or the user
   * cancels.
   * @param {number=} timeoutMillis The timeout in milliseconds.
   * @return {!Promise<string>} Fulfilled with the source ID.
   * @private
   */
Requests a screen capture source from the user via a native dialog and
returns the source ID, or rejects if a timeout is reached or the user
cancels.
@param {number=} timeoutMillis The timeout in milliseconds.
@return {!Promise} Fulfilled with the source ID.
@private
Requests a screen capture source from the user via a native dialog and returns the source ID or rejects if a timeout is reached or the user cancels . @param { number = } timeoutMillis The timeout in milliseconds . @return { !Promise } Fulfilled with the source ID . @private
requestScreenCaptureSourceId_(
      timeoutMillis = mr.mirror.MirrorMediaStream.WINDOW_PICKER_TIMEOUT_) {
    return new Promise((resolve, reject) => {
      const desktopChooserConfig = ['screen', 'audio'];
      if (mr.PlatformUtils.getCurrentOS() == mr.PlatformUtils.OS.LINUX) {
        desktopChooserConfig.push('window');
      }
      let requestId;
      const timeoutId = window.setTimeout(() => {
        if (requestId) {
          chrome.desktopCapture.cancelChooseDesktopMedia(requestId);
        }
        reject(new mr.mirror.Error(
            'timeout',
            mr.MirrorAnalytics.CapturingFailure
                .CAPTURE_DESKTOP_FAIL_ERROR_TIMEOUT));
      }, timeoutMillis);
      requestId = chrome.desktopCapture.chooseDesktopMedia(
          desktopChooserConfig, sourceId => {
            window.clearTimeout(timeoutId);
            if (!sourceId) {
              reject(new mr.mirror.Error(
                  'User cancelled capture dialog',
                  mr.MirrorAnalytics.CapturingFailure
                      .CAPTURE_DESKTOP_FAIL_ERROR_USER_CANCEL));
            } else {
              resolve(sourceId);
            }
          });
    });
  }
requestScreenCaptureSourceId_ ( timeoutMillis = mr . mirror . MirrorMediaStream . WINDOW_PICKER_TIMEOUT_ ) { return new Promise ( ( resolve , reject ) => { const desktopChooserConfig = [ 'screen' , 'audio' ] ; if ( mr . PlatformUtils . getCurrentOS ( ) == mr . PlatformUtils . OS . LINUX ) { desktopChooserConfig . push ( 'window' ) ; } let requestId ; const timeoutId = window . setTimeout ( ( ) => { if ( requestId ) { chrome . desktopCapture . cancelChooseDesktopMedia ( requestId ) ; } reject ( new mr . mirror . Error ( 'timeout' , mr . MirrorAnalytics . CapturingFailure . CAPTURE_DESKTOP_FAIL_ERROR_TIMEOUT ) ) ; } , timeoutMillis ) ; requestId = chrome . desktopCapture . chooseDesktopMedia ( desktopChooserConfig , sourceId => { window . clearTimeout ( timeoutId ) ; if ( ! sourceId ) { reject ( new mr . mirror . Error ( 'User cancelled capture dialog' , mr . MirrorAnalytics . CapturingFailure . CAPTURE_DESKTOP_FAIL_ERROR_USER_CANCEL ) ) ; } else { resolve ( sourceId ) ; } } ) ; } ) ; }
Requests a screen capture source from the user via a native dialog and
 returns the source ID, or rejects if a timeout is reached or the user
 cancels.
Requests a screen capture source from the user via a native dialog and returns the source ID or rejects if a timeout is reached or the user cancels .
// Wait 60 seconds and then cancel the picker and reject the // promise. // https://developer.chrome.com/extensions/desktopCapture#method-chooseDesktopMedia // User cancelled the desktop media selector prompt.