欢迎 What's new in Chrome extensions Get help with Chrome extensions API reference Samples
欢迎 What's new in Chrome extensions Get help with Chrome extensions API reference Samples

chrome.tabCapture

  • Description

    Use the chrome.tabCapture API to interact with tab media streams.

  • Permissions
    tabCapture
    This permission triggers a warning.
  • Availability
    Foreground only

Summary

Types

CaptureInfo

Properties

  • fullscreen

    boolean

    Whether an element in the tab being captured is in fullscreen mode.

  • The new capture status of the tab.

  • tabId

    number

    The id of the tab whose status changed.

CaptureOptions

Properties

GetMediaStreamOptions

Chrome 71+

Properties

  • consumerTabId

    number optional

    Optional tab id of the tab which will later invoke getUserMedia() to consume the stream. If not specified then the resulting stream can be used only by the calling extension. The stream can only be used by frames in the given tab whose security origin matches the consumber tab's origin. The tab's origin must be a secure origin, e.g. HTTPS.

  • targetTabId

    number optional

    Optional tab id of the tab which will be captured. If not specified then the current active tab will be selected. Only tabs for which the extension has been granted the activeTab permission can be used as the target tab.

MediaStreamConstraint

Properties

  • mandatory

    object

  • optional

    object optional

TabCaptureState

Type

"pending"

,

"active"

,

"stopped"

,
or

"error"

Methods

capture

chrome.tabCapture.capture(
  options: CaptureOptions,
  callback: function,
)

Captures the visible area of the currently active tab. Capture can only be started on the currently active tab after the extension has been invoked, similar to the way that activeTab works. Capture is maintained across page navigations within the tab, and stops when the tab is closed, or the media stream is closed by the extension.

Parameters

  • Configures the returned media stream.

  • callback

    function

    The callback parameter looks like: (stream: LocalMediaStream) => void

    • stream

      LocalMediaStream

getCapturedTabs

chrome.tabCapture.getCapturedTabs(
  callback: function,
)

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

getMediaStreamId

chrome.tabCapture.getMediaStreamId(
  options?: GetMediaStreamOptions,
  callback: function,
)
Chrome 71+

Creates a stream ID to capture the target tab. Similar to chrome.tabCapture.capture() method, but returns a media stream ID, instead of a media stream, to the consumer tab.

Parameters

  • options
  • callback

    function

    The callback parameter looks like: (streamId: string) => void

    • streamId

      string

Events

onStatusChanged

chrome.tabCapture.onStatusChanged.addListener(
  callback: function,
)

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 in sync.

Parameters

We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.