@sswahn/camera

1.0.2 • Public • Published

Camera · License npm version Weekly Downloads GitHub stars

Camera provides a set of methods for managing video and audio streams from a device's camera and microphone. This library offers functionalities like starting/stopping the camera, toggling the light, muting audio, capturing photos, and recording videos.

Features

  • Start and stop the device's camera with custom constraints.
  • Capture still photos from the video stream.
  • Record video clips.
  • Toggle camera light (if supported by the device).
  • Mute and unmute audio.

Installation

Using npm.

npm install @sswahn/camera

Usage

Here's a brief overview of the functionalities provided:

Import Camera

import camera from '@sswahn/camera'

Turn The Camera On

const stream = await camera.on(optionalConstraints)

Display The Stream

videoRef.current.srcObject = stream
...
<video ref={videoRef} autoPlay muted></video>

Take Photos

const videoElement = videoRef.current
const blob = await camera.takePhoto(videoElement)

Start Recording

const frames = []
const recorder = camera.startRecording(stream, frames)

Stop Recording

const blob = await camera.stopRecording(recorder, frames)

Turn The Camera Off

camera.off(stream)

Turn On Light

camera.light(stream)

Turn Off Light

camera.dark(stream)

Mute Audio

camera.mute(stream)

Unmute Audio

camera.unmute(stream)

License

Camera is MIT Licensed

/@sswahn/camera/

    Package Sidebar

    Install

    npm i @sswahn/camera

    Weekly Downloads

    5

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    9.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • sswahn