MediaDevices


How to use the MediaDevices class of the bit Butil?

Usage
Inject the MediaDevices class, enumerate the available cameras and microphones, request a live stream, and attach it to a video element:
@inject Bit.Butil.MediaDevices mediaDevices

@code {
    var devices = await mediaDevices.EnumerateDevices();
    var stream  = await mediaDevices.GetUserMedia(audio: true, video: true);
    await stream.AttachTo(videoElement);
}
Methods
The MediaDevices class wraps navigator.mediaDevices.

IsSupported:
Returns whether navigator.mediaDevices is available in the current browser (MDN).



EnumerateDevices:
Lists all input/output media devices. Labels may be empty until the user has granted permission to a matching input (MDN).



GetUserMedia / AttachTo / SetEnabled:
Requests camera and/or microphone access and returns a MediaStreamHandle (or null when the user denies the prompt). Attach the stream to a video element with AttachTo, pause or resume its tracks with SetEnabled, and stop the stream by disposing the handle (MDN).