chrome.tabCapture

Description: Use the chrome.tabCapture API to interact with tab media streams.
Availability: Stable since Chrome 31.
Permissions: "tabCapture"

Summary

Types
CaptureInfo
MediaStreamConstraint
Methods
capture chrome.tabCapture.capture(object options, function callback)
getCapturedTabs chrome.tabCapture.getCapturedTabs(function callback)
Events
onStatusChanged

Types

CaptureInfo

properties
integer tabId The id of the tab whose status changed.
enum of "pending", "active", "stopped", or "error" status The new capture status of the tab.
boolean fullscreen Whether an element in the tab being captured is in fullscreen mode.

MediaStreamConstraint

properties
object mandatory
object (optional) optional

Methods

capture

chrome.tabCapture.capture(object options, function callback)

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 activeTab works.

Parameters
object options Configures the returned media stream.
boolean (optional) audio
boolean (optional) video
MediaStreamConstraint (optional) audioConstraints
MediaStreamConstraint (optional) videoConstraints
function callback Callback with either the stream returned or null.

The callback parameter should be a function that looks like this:

function(LocalMediaStream stream) {...};
LocalMediaStream stream

getCapturedTabs

chrome.tabCapture.getCapturedTabs(function callback)

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).

Parameters
function callback

The callback parameter should be a function that looks like this:

function(array of CaptureInfo result) {...};
array of CaptureInfo result

Events

onStatusChanged

Event fired when the capture status of a tab changes. This allows extension authors to keep track of the capture status of tabs to keep UI elements like page actions and infobars in sync.

addListener

chrome.tabCapture.onStatusChanged.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function( CaptureInfo info) {...};
CaptureInfo info