Dart Documentationchrome.tabCaptureChromeTabCapture

ChromeTabCapture class

class ChromeTabCapture extends ChromeApi {
 static final JsObject _tabCapture = chrome['tabCapture'];

 ChromeTabCapture._();

 bool get available => _tabCapture != null;

 /**
  * Captures the visible area of the currently active tab. This method can only
  * be used on the currently active page after the extension has been
  * _invoked_, similar to the way that <a href="activeTab.html">activeTab</a>
  * works.
  * [options]: Configures the returned media stream.
  * [callback]: Callback with either the stream returned or null.
  */
 Future<LocalMediaStream> capture(CaptureOptions options) {
   if (_tabCapture == null) _throwNotAvailable();

   var completer = new ChromeCompleter<LocalMediaStream>.oneArg(_createLocalMediaStream);
   _tabCapture.callMethod('capture', [jsify(options), completer.callback]);
   return completer.future;
 }

 /**
  * Returns a list of tabs that have requested capture or are being captured,
  * i.e. status != stopped and status != error. This allows extensions to
  * inform the user that there is an existing tab capture that would prevent a
  * new tab capture from succeeding (or to prevent redundant requests for the
  * same tab).
  */
 Future<List<CaptureInfo>> getCapturedTabs() {
   if (_tabCapture == null) _throwNotAvailable();

   var completer = new ChromeCompleter<List<CaptureInfo>>.oneArg((e) => listify(e, _createCaptureInfo));
   _tabCapture.callMethod('getCapturedTabs', [completer.callback]);
   return completer.future;
 }

 Stream<CaptureInfo> get onStatusChanged => _onStatusChanged.stream;

 final ChromeStreamController<CaptureInfo> _onStatusChanged =
     new ChromeStreamController<CaptureInfo>.oneArg(_tabCapture, 'onStatusChanged', _createCaptureInfo);

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

Extends

ChromeApi > ChromeTabCapture

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 => _tabCapture != null;

final Stream<CaptureInfo> onStatusChanged #

Stream<CaptureInfo> get onStatusChanged => _onStatusChanged.stream;

Methods

Future<LocalMediaStream> capture(CaptureOptions options) #

Captures the visible area of the currently active tab. This method can only be used on the currently active page after the extension has been invoked, similar to the way that <a href="activeTab.html">activeTab</a> works. options: Configures the returned media stream. callback: Callback with either the stream returned or null.

Future<LocalMediaStream> capture(CaptureOptions options) {
 if (_tabCapture == null) _throwNotAvailable();

 var completer = new ChromeCompleter<LocalMediaStream>.oneArg(_createLocalMediaStream);
 _tabCapture.callMethod('capture', [jsify(options), completer.callback]);
 return completer.future;
}

Future<List<CaptureInfo>> getCapturedTabs() #

Returns a list of tabs that have requested capture or are being captured, i.e. status != stopped and status != error. This allows extensions to inform the user that there is an existing tab capture that would prevent a new tab capture from succeeding (or to prevent redundant requests for the same tab).

Future<List<CaptureInfo>> getCapturedTabs() {
 if (_tabCapture == null) _throwNotAvailable();

 var completer = new ChromeCompleter<List<CaptureInfo>>.oneArg((e) => listify(e, _createCaptureInfo));
 _tabCapture.callMethod('getCapturedTabs', [completer.callback]);
 return completer.future;
}