1.0.2 • Published 6 months ago

@sswahn/camera v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago

1.0.0-beta.4

6 months ago

1.0.0-beta.3

6 months ago

1.0.0-beta.2

6 months ago

1.0.0-beta.1

6 months ago

1.0.0-beta.0

6 months ago