CameraController

Hierarchy

  • EventTarget
    • CameraController

Constructors

Properties

cameraFrameRate: number = 0
cameraHeight: number = 0
cameraStream: null | MediaStream = null
cameraWidth: number = 0
mediaDevices: MediaDevice[] = []
selectedDeviceId: string = ''
settingsInputIds: string[] = ...
standardSettingsIds: string[] = ...
videoTrackCapabilities: VideoTrackCapabilities = {}

Methods

  • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optionaloptions: boolean | AddEventListenerOptions

    Returns void

  • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optionaloptions: boolean | AddEventListenerOptions

    Returns void

  • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • Enumerates the list of video input devices

    The label field for each MediaDevice will be empty if the permission is not equal to granted

    Returns Promise<MediaDevice[]>

  • Return VideoTrackCapabilities

    Returns VideoTrackCapabilities

  • Populates the list of mediaDevices and sets selectedDeviceId

    If camera permission granted it will populate mediaDevices with the list of available cameras and sets selectedDeviceId to that of the first available camera.

    If camera permission is blocked, it will set mediaDevices to [] and selectedDeviceId to an empty string

    Returns Promise<void>

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optionaloptions: boolean | EventListenerOptions

    Returns void

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optionaloptions: boolean | EventListenerOptions

    Returns void

  • Requests camera permissions from the user.

    Returns Promise<RequestPermissionResult>

    Promise

  • Change selected media device Id

    Parameters

    • deviceId: string

    Returns void

  • Starts the camera.

    Camera selection is performed using one of the following methods:

    • If facingMode is provided, the browser selects a camera matching the requested facing direction (user or environment). When multiple cameras satisfy the requested facing mode, the browser decides which camera to open.
    • If facingMode is not provided, the currently selected camera (selectedDeviceId) is opened.

    After a camera is successfully opened, selectedDeviceId is updated to the deviceId of the active camera when available. This allows a camera selected via facingMode to be reopened later using its exact deviceId.

    Parameters

    • frameWidth: number

      Desired frame width. Must use a 16:9 aspect ratio.

    • frameHeight: number

      Desired frame height. Must use a 16:9 aspect ratio.

    • OptionalfacingMode: "user" | "environment"

      Optional camera facing direction. When provided, camera selection is performed by facing mode instead of selectedDeviceId.

    Returns Promise<boolean>

    true if the camera was opened successfully; otherwise false.

  • Stop camera

    Returns void

  • Returns void