A MediaStream is a stream of media—usually audio and/or video from a camera or microphone. Browsers often create one through navigator.mediaDevices.getUserMedia().
A stream holds one or more MediaStreamTrack objects. Inspect them with getTracks(), add with addTrack(), and remove with removeTrack(). Assign the stream to video.srcObject to show it.
This page teaches what MediaStream is. Constructor, methods, and properties live under this section.
Permission is required.
getUserMedia asks the user for camera or mic access. Without permission the promise rejects.
A MediaStream is a collection of media tracks, such as microphone audio and camera video, that you can play in a video element or send over a connection.
Call navigator.mediaDevices.getUserMedia({ video: true }). The user must allow permission. The promise resolves with a MediaStream.
Set videoElement.srcObject = stream. Do not use createObjectURL for this modern path.
Call stop() on each track from stream.getTracks(). That ends capture and usually turns off the indicator.
Open the MediaStream constructor, then Navigator for mediaDevices helpers.