@sswahn/camera
v1.0.2
Published
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.
Downloads
10
Maintainers
Readme
Camera ·
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