Dart Documentationchrome.desktopCaptureChromeDesktopCapture

ChromeDesktopCapture class

class ChromeDesktopCapture extends ChromeApi {
 static final JsObject _desktopCapture = chrome['desktopCapture'];

 ChromeDesktopCapture._();

 bool get available => _desktopCapture != null;

 /**
  * Shows desktop media picker UI with the specified set of sources.
  * 
  * [sources] Set of sources that should be shown to the user.
  * 
  * [targetTab] Optional tab for which the stream is created. If not specified
  * then the resulting stream can be used only by the calling extension,
  * otherwise the stream can be used only by the specified tab. If the tab's
  * security origin changes before this function returns, the call may fail.
  * 
  * Returns:
  * An id that can be passed to cancelChooseDesktopMedia() in case the prompt
  * need to be canceled.
  */
 int chooseDesktopMedia(List<DesktopCaptureSourceType> sources, dynamic callback, [Tab targetTab]) {
   if (_desktopCapture == null) _throwNotAvailable();

   return _desktopCapture.callMethod('chooseDesktopMedia', [jsify(sources), jsify(targetTab), jsify(callback)]);
 }

 /**
  * Hides desktop media picker dialog shown by chooseDesktopMedia().
  * 
  * [desktopMediaRequestId] Id returned by chooseDesktopMedia()
  */
 void cancelChooseDesktopMedia(int desktopMediaRequestId) {
   if (_desktopCapture == null) _throwNotAvailable();

   _desktopCapture.callMethod('cancelChooseDesktopMedia', [desktopMediaRequestId]);
 }

 void _throwNotAvailable() {
   throw new UnsupportedError("'chrome.desktopCapture' is not available");
 }
}

Extends

ChromeApi > ChromeDesktopCapture

Properties

final bool available #

Returns true if the API is available. The common causes of an API not being avilable are:

  • a permission is missing in the application's manifest.json file
  • the API is defined on a newer version of Chrome then the current runtime
docs inherited from ChromeApi
bool get available => _desktopCapture != null;

Methods

void cancelChooseDesktopMedia(int desktopMediaRequestId) #

Hides desktop media picker dialog shown by chooseDesktopMedia().

desktopMediaRequestId Id returned by chooseDesktopMedia()

void cancelChooseDesktopMedia(int desktopMediaRequestId) {
 if (_desktopCapture == null) _throwNotAvailable();

 _desktopCapture.callMethod('cancelChooseDesktopMedia', [desktopMediaRequestId]);
}

int chooseDesktopMedia(List<DesktopCaptureSourceType> sources, callback, [Tab targetTab]) #

Shows desktop media picker UI with the specified set of sources.

sources Set of sources that should be shown to the user.

targetTab Optional tab for which the stream is created. If not specified then the resulting stream can be used only by the calling extension, otherwise the stream can be used only by the specified tab. If the tab's security origin changes before this function returns, the call may fail.

Returns: An id that can be passed to cancelChooseDesktopMedia() in case the prompt need to be canceled.

int chooseDesktopMedia(List<DesktopCaptureSourceType> sources, dynamic callback, [Tab targetTab]) {
 if (_desktopCapture == null) _throwNotAvailable();

 return _desktopCapture.callMethod('chooseDesktopMedia', [jsify(sources), jsify(targetTab), jsify(callback)]);
}