A RetroSearch Logo

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

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/captureStream below:

HTMLMediaElement: captureStream() method - Web APIs

HTMLMediaElement: captureStream() method

Limited availability

The captureStream() method of the HTMLMediaElement interface returns a MediaStream object which is streaming a real-time capture of the content being rendered in the media element.

This can be used, for example, as a source for a WebRTC RTCPeerConnection.

Syntax Parameters

None.

Return value

A MediaStream object which can be used as a source for audio and/or video data by other media processing code, or as a source for WebRTC.

Examples

In this example, an event handler is established so that clicking a button starts capturing the contents of a media element with the ID "playback" into a MediaStream. The stream can then be used for other purposes—like a source for streaming over WebRTC, to allow sharing prerecorded videos with another person during a video call.

document.querySelector(".playAndRecord").addEventListener("click", () => {
  const playbackElement = document.getElementById("playback");
  const captureStream = playbackElement.captureStream();
  playbackElement.play();
});

See Recording a media element for a longer and more intricate example and explanation.

Specifications Browser compatibility Firefox-specific notes

Prior to Firefox 51, you couldn't use captureStream() on a media element whose source is, itself, a MediaStream (like a <video> element which is presenting a stream being received over a RTCPeerConnection). Beginning in Firefox 51, this works. This means you can capture a stream from the video element and use MediaRecorder to record it. See Firefox bug 1259788 for details.

However, captureStream() is still prefixed as mozCaptureStream() on Firefox for good reason: there are some quirks in the present implementation which are worth noting:

See also

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