ImageCapture: ImageCapture() constructor
TheImageCapture()
constructorcreates a newImageCapture
object.
In this article
Syntax
js
new ImageCapture(videoTrack)
Parameters
videoTrack
A
MediaStreamTrack
from which the still images will be taken. Thiscan be any source, such as an incoming stream of a video conference, a playing movie,or the stream from a webcam.
Return value
A newImageCapture
object which can be used to capture still frames fromthe specified video track.
Exceptions
NotSupportedError
DOMException
Thrown if the
videoTrack
parameter'skind
property is notvideo
.
Examples
The following example shows how to use a call toMediaDevices.getUserMedia()
to retrieve theMediaStreamTrack
needed by theImageCapture()
constructor.
js
navigator.mediaDevices .getUserMedia({ video: true }) .then((mediaStream) => { document.querySelector("video").srcObject = mediaStream; const track = mediaStream.getVideoTracks()[0]; imageCapture = new ImageCapture(track); }) .catch((error) => console.error(error));
Specifications
Specification |
---|
MediaStream Image Capture> # dom-imagecapture-imagecapture> |
Browser compatibility
Loading…