Search completed in 1.45 seconds.
HTMLCanvasElement.captureStream() - Web APIs
If not set, a new frame will be captured each time the canvas changes; if set to 0, frames will not be captured automatically; instead, they will only be captured when the returned track's requestFrame() method is called. Return value A reference to a MediaStream object, which has a single CanvasCaptureMediaStreamTrack in it. Exceptions NotSupportedError The value of frameRate is negative. ...
...ill only be captured when the returned track's requestFrame() method is called. Return value A reference to a MediaStream object, which has a single CanvasCaptureMediaStreamTrack in it. Exceptions NotSupportedError The value of frameRate is negative. Example // Find the canvas element to capture var canvasElt = document.querySelector('canvas'); // Get the stream var stream = canvasElt.
captureStream(25); // 25 FPS // Do things to the stream // E.g. Send it to another computer using an RTCPeerConnection // pc is an RTCPeerConnection created elsewhere pc.addStream(stream); Specifications Specification Status Comment Media Capture from DOM ElementsThe definition of 'HTMLCanvasElement.
captureStream()' in that specification. Working Draft Initial definit...
HTMLMediaElement.captureStream() - Web APIs
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. Example 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. ...
... 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', function() { var playbackElement = document.getElementById("playback"); var
captureStream = playbackElement.
captureStream(); playbackElement.play(); }); See Recording a media element for a longer and more intricate example and explanation. Specifications Specification Status Comment Media Capture from DOM ElementsThe definition of '
captureStream()' in that specification. Working Draft Initial definition. ...
Index - Web APIs
535 CanvasCaptureMediaStreamTrack.canvas Canvas, CanvasCaptureMediaStreamTrack, Experimental, Frame Capture, Media Capture, Property, Read-only, Reference, Web The CanvasCaptureMediaStreamTrack canvas read-only property returns the HTMLCanvasElement from which frames are being captured. 536 CanvasCaptureMediaStreamTrack.requestFrame() Canvas, CanvasCaptureMe...
...ments associated with the <button> element. 1582 HTMLCanvasElement API, Canvas, HTML DOM, Interface, Reference The HTMLCanvasElement interface provides properties and methods for manipulating the layout and presentation of <canvas> elements. The HTMLCanvasElement interface also inherits the properties and methods of the HTMLElement interface. 1583 HTMLCanvasElement.
captureStream() Canvas, Experimental, Frame Capture, HTMLCanvasElement, Interface, Media, Media Capture DOM Elements, Method, Reference, Web,
captureStream The HTMLCanvasElement
captureStream() method returns a MediaStream which includes a CanvasCaptureMediaStreamTrack containing a real-time video capture of the canvas's contents. 1584 HTMLCanvasElement.getContext() API, Canvas, HTMLCa...
...ed. 1770 HTMLMediaElement.canPlayType() API, Audio, Capability, Compatibility, Format, HTML DOM, HTMLMediaElement, MIME Types, Media, Media Types, Method, Reference, Type, Video, Web, canPlayType, support The HTMLMediaElement method canPlayType() reports how likely it is that the current browser will be able to play media of a given MIME type. 1771 HTMLMediaElement.
captureStream() API, Audio, HTML DOM, HTMLMediaElement, Media, Media Capture DOM Elements, Method, Reference, Video,
captureStream The
captureStream() property of the HTMLMediaElement interface returns a MediaStream object which is streaming a real-time capture of the content being rendered in the media element. 1772 HTMLMediaElement.controller API, HTML DOM, HTMLMediaElement, Property...
Recording a media element - Web APIs
m. ...
...eam and setting up the recorder Now let's look at the most intricate piece of code in this example: our event handler for clicks on the start button: startButton.addEventListener("click", function() { navigator.mediaDevices.getUserMedia({ video: true, audio: true }).then(stream => { preview.srcObject = stream; downloadButton.href = stream; preview.
captureStream = preview.
captureStream || preview.moz
CaptureStream; return new Promise(resolve => preview.onplaying = resolve); }).then(() => startRecording(preview.
captureStream(), recordingTimeMS)) .then (recordedChunks => { let recordedBlob = new Blob(recordedChunks, { type: "video/webm" }); recording.src = URL.createObjectURL(recordedBlob); downloadButton.href = recording.src; downloadButton.download = "Rec...
...n the Promise returned by getUserMedia() is resolved, the preview <video> element's srcObject property is set to be the input stream, which causes the video being captured by the user's camera to be displayed in the preview box. Since the <video> element is muted, the audio won't play. The "Download" button's link is then set to refer to the stream as well. Then, in line 8, we arrange for preview.
captureStream() to call preview.moz
CaptureStream() so that our code will work on Firefox, on which the MediaRecorder.
captureStream() method is prefixed. Then a new Promise which resolves when the preview video starts to play is created and returned. Line 10 When the preview video begins to play, we know there's media to record, so we respond by calling the startRecording() function we created earlier, passin...
Using the Screen Capture API - Web APIs
standard API. This works with at least Chrome, Edge, and Firefox. Capturing screen contents Capturing screen contents as a live MediaStream is initiated by calling navigator.mediaDevices.getDisplayMedia(), which returns a promise that resolves to a stream containing the live screen contents. Starting screen capture: async/await style async function startCapture(displayMediaOptions) { let
captureStream = null; try {
captureStream = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions); } catch(err) { console.error("Error: " + err); } return
captureStream; } You can write this code either using an asynchronous function and the await operator, as shown above, or using the Promise directly, as seen below. Starting screen capture: Promise style function startCapture...
...Stream = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions); } catch(err) { console.error("Error: " + err); } return
captureStream; } You can write this code either using an asynchronous function and the await operator, as shown above, or using the Promise directly, as seen below. Starting screen capture: Promise style function startCapture(displayMediaOptions) { let
captureStream = null; return navigator.mediaDevices.getDisplayMedia(displayMediaOptions) .catch(err => { console.error("Error:" + err); return null; }); } Either way, the user agent responds by presenting a user interface that prompts the user to choose the screen area to share. Both of these implementations of startCapture() return the MediaStream containing the captured display imagery. See Options a...
...area to share. Both of these implementations of startCapture() return the MediaStream containing the captured display imagery. See Options and constraints, below, for more on both how to specify the type of surface you want as well as other ways to adjust the resulting stream. Example of a window allowing the user to select a display surface to capture You can then use the captured stream,
captureStream, for anything that accepts a stream as input. The examples below show a few ways to make use of the stream. Visible vs logical display surfaces For the purposes of the Screen Capture API, a display surface is any content object that can be selected by the API for sharing purposes. Sharing surfaces include the contents of a browser tab, a complete window, all of the applications of a window comb...
CanvasCaptureMediaStreamTrack.requestFrame() - Web APIs
Track method requestFrame() requests that a frame be captured from the canvas and sent to the stream. Applications that need to carefully control the timing of rendering and frame capture can use requestFrame() to directly specify when it's time to capture a frame. To prevent automatic capture of frames, so that frames are only captured when requestFrame() is called, specify a value of 0 for the
captureStream() method when creating the stream. Syntax stream.requestFrame(); Return value undefined Usage notes There is currently an issue flagged in the specification pointing out that at this time, no exceptions are being thrown if the canvas isn't origin-clean. This may change in the future, so it would be wise to plan ahead and watch for exceptions such as SecurityError (although the specific err...
...e canvas isn't origin-clean. This may change in the future, so it would be wise to plan ahead and watch for exceptions such as SecurityError (although the specific error that might be thrown is not mentioned in the spec, this is a likely candidate). Example // Find the canvas element to capture var canvasElt = document.getElementsByTagName("canvas")[0]; // Get the stream var stream = canvasElt.
captureStream(25); // 25 FPS // Send the current state of the canvas as a frame to the stream stream.getVideoTracks()[0].requestFrame(); Specifications Specification Status Comment Media Capture from DOM ElementsThe definition of 'CanvasCaptureMediaStream.requestFrame()' in that specification. Working Draft Initial definition ...
HTMLCanvasElement - Web APIs
at implements the MozCanvasPrintState interface. The callback can get the context to draw to from the printState object and must then call done() on it when finished. The purpose of mozPrintCallback is to obtain a higher resolution rendering of the canvas at the resolution of the printer being used. See this blog post. Methods Inherits methods from its parent, HTMLElement. HTMLCanvasElement.
captureStream() Returns a CanvasCaptureMediaStream that is a real-time video capture of the surface of the canvas. HTMLCanvasElement.getContext() Returns a drawing context on the canvas, or null if the context ID is not supported. A drawing context lets you draw on the canvas. Calling getContext with "2d" returns a CanvasRenderingContext2D object, whereas calling it with "webgl" (or "experimental-webgl") ...
... ...
HTMLMediaElement - Web APIs
Sets the EventHandler called when the interruption is concluded. This was Firefox-specific, having been implemented for Firefox OS, and was removed in Firefox 55. Methods This interface also inherits methods from its ancestors HTMLElement, Element, Node, and EventTarget. HTMLMediaElement.addTextTrack() Adds a text track (such as a track for subtitles) to a media element. HTMLMediaElement.
captureStream() Returns MediaStream, captures a stream of the media content. HTMLMediaElement.canPlayType() Given a string specifying a MIME media type (potentially with the codecs parameter included), canPlayType() returns the string probably if the media should be playable, maybe if there's not enough information to determine whether the media will play or not, or an empty string if the media cannot be ...
...e, maybe if there's not enough information to determine whether the media will play or not, or an empty string if the media cannot be played. HTMLMediaElement.fastSeek() Directly seeks to the given time. HTMLMediaElement.load() Resets the media to the beginning and selects the best available source from the sources provided using the src attribute or the <source> element. HTMLMediaElement.moz
CaptureStream() [enter description] HTMLMediaElement.moz
CaptureStreamUntilEnded() [enter description] HTMLMediaElement.mozGetMetadata() Returns Object, which contains properties that represent metadata from the playing media resource as {key: value} pairs. A separate copy of the data is returned each time the method is called. This method must be called after the loadedmetadata event fires. HTMLMed...
CanvasCaptureMediaStreamTrack.canvas - Web APIs
ureMediaStreamTrack canvas read-only property returns the HTMLCanvasElement from which frames are being captured. Syntax var elt = stream.canvas; Value An HTMLCanvasElement indicating the canvas which is the source of the frames being captured. Example // Find the canvas element to capture var canvasElt = document.getElementsByTagName("canvas")[0]; // Get the stream var stream = canvasElt.
captureStream(25); // 25 FPS // Do things to the stream ... // Obtain the canvas associated with the stream var canvas = stream.canvas; Specifications Specification Status Comment Media Capture from DOM ElementsThe definition of 'CanvasCaptureMediaStreamTrack.canvas' in that specification. Working Draft Initial definition ...
CanvasCaptureMediaStreamTrack - Web APIs
The CanvasCaptureMediaStreamTrack interface represents the video track contained in a MediaStream being generated from a <canvas> following a call to HTMLCanvasElement.
captureStream(). Part of the Media Capture and Streams API. Properties This interface inherits the properties of its parent, MediaStreamTrack. CanvasCaptureMediaStreamTrack.canvas Read only Returns the HTMLCanvasElement object whose surface is captured in real-time. Methods This interface inherits the methods of its parent, MediaStreamTrack. CanvasCaptureMediaStreamTrack.requestFrame() Manually forces a frame to be captured and sent to the stream. This lets applications that wish to specify the frame capture times directly do so, if they specified a frameRate of 0 when calling
captureStream(). Specifications S...
MediaDevices.getDisplayMedia() - Web APIs
n the example below, a startCapture() method is created which initiates screen capture given a set of options specified by the displayMediaOptions parameter. The options are specified in the form of a MediaStreamConstraints object which specifies the preferred stream configuration and the display surface from which video is to be captured. async function startCapture(displayMediaOptions) { let
captureStream = null; try {
captureStream = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions); } catch(err) { console.error("Error: " + err); } return
captureStream; } This uses await to asynchronously wait for getDisplayMedia() to resolve with a MediaStream which contains the display contents as requested by the specified options. The stream is then returned to the caller for...
MediaStream.onaddtrack - Web APIs
The MediaStream.onaddtrack property is an EventHandler which specifies a function to be called when the addtrack event occurs on a MediaStream instance. This happens when a new track of any kind is added to the media stream. This event is fired when the browser adds a track to the stream (such as when a RTCPeerConnection is renegotiated or a stream being captured using HTMLMediaElement.
captureStream() gets a new set of tracks because the media element being captured loaded a new source. The addtrack event does not get fired when JavaScript code explicitly adds tracks to the stream (by calling addTrack()). Syntax MediaStream.onaddtrack = eventHandler; Value This should be set to a function which you provide that accepts as input a MediaStreamTrackEvent object representing the addtrack event which...
MediaStream.onremovetrack - Web APIs
The MediaStream.onremovetrack property is an EventHandler which specifies a function to be called when the removetrack event occurs on a MediaStream instance. This happens when a track of any kind is removed from the media stream. This event is fired when the browser removes a track from the stream (such as when a RTCPeerConnection is renegotiated or a stream being captured using HTMLMediaElement.
captureStream() gets a new set of tracks because the media element being captured loaded a new source. The removetrack event does not get fired when JavaScript code explicitly removes tracks from the stream (by calling removeTrack()). Syntax MediaStream.onremovetrack = eventHandler; Value This should be set to a function which you provide that accepts as input a MediaStreamTrackEvent object representing ...
MediaStream Recording API - Web APIs
assembled before playback. If anything goes wrong during recording, an error event is sent to the MediaRecorder. You can listen for error events by setting up a onerror event handler. Example here, we use an HTML Canvas as source of the MediaStream, and stop recording after 9 seconds. var canvas = document.querySelector("canvas"); // Optional frames per second argument. ...
Screen Capture API - Web APIs
others over the network. Screen Capture API concepts and usage The Screen Capture API is relatively simple to use. Its sole method is MediaDevices.getDisplayMedia(), whose job is to ask the user to select a screen or portion of a screen to capture in the form of a MediaStream. To start capturing video from the screen, you call getDisplayMedia() on the instance of Media navigator.mediaDevices:
captureStream = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions); The Promise returned by getDisplayMedia() resolves to a MediaStream which streams the captured media. See the article Using the Screen Capture API for a more in-depth look at how to use the API to capture screen contents as a stream. Additions to existing interfaces The Screen Capture API doesn't have any interfaces of its o...