A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.chrome.com/docs/extensions/reference/api/tabCapture below:

chrome.tabCapture | API | Chrome for Developers

Skip to main content chrome.tabCapture

Stay organized with collections Save and categorize content based on your preferences.

Description

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

Permissions

tabCapture

Concepts and usage

The chrome.tabCapture API lets you access a MediaStream containing video and audio of the current tab. It can only be called after the user invokes an extension, such as by clicking the extension's action button. This is similar to the behavior of the "activeTab" permission.

Preserve system audio

When a MediaStream is obtained for a tab, audio in that tab will no longer be played to the user. This is similar to the behavior of the getDisplayMedia() function when the suppressLocalAudioPlayback flag is set to true.

To continue playing audio to the user, use the following:

const output = new AudioContext();
const source = output.createMediaStreamSource(stream);
source.connect(output.destination);

This creates a new AudioContext and connects the audio of the tab's MediaStream to the default destination.

Stream IDs

Calling chrome.tabCapture.getMediaStreamId() will return a stream ID. To later access a MediaStream from the ID, use the following:

navigator.mediaDevices.getUserMedia({
  audio: {
    mandatory: {
      chromeMediaSource: "tab",
      chromeMediaSourceId: id,
    },
  },
  video: {
    mandatory: {
      chromeMediaSource: "tab",
      chromeMediaSourceId: id,
    },
  },
});
Usage restrictions

After calling getMediaStreamId(), there are restrictions on where the returned stream ID can be used:

Prior to Chrome 116, when a consumerTabId was not specified, the stream ID was restricted to both the security origin, render process and render frame of the caller.

Learn more

To learn more about how to use the chrome.tabCapture API, see Audio recording and screen capture. This demonstrates how to use tabCapture and related APIs to solve a number of common use cases.

Types Properties Properties Enum

"pending"

"active"

"stopped"

"error"

Methods

capture()

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

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

getCapturedTabs()

chrome.tabCapture.getCapturedTabs(): Promise<CaptureInfo[]>

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

getMediaStreamId()

chrome.tabCapture.getMediaStreamId(
  options?: GetMediaStreamOptions,
)
: Promise<string>

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.

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

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-11 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-11 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4