0.3.0 • Published 6 years ago

react-user-media v0.3.0

Weekly downloads
276
License
MIT
Repository
github
Last release
6 years ago

react-user-media

Provides components for access to audio and webcam

Instalation

npm install react-user-media
import Webcam from "react-user-media";

Webcam

Renders a video element that autoplays the feed from the user's webcam (if allowed). If used with a ref, it's possible to take screenshots of the video feed to a data url format.

Basic usage

<Webcam />

Advanced usage (screenshots)

In your component, render Webcam along with a ref:

<Webcam ref={(ref) => this.webcam = ref} />

and then use that ref to access the captureScreenshot method. This methods returns a string with a data-url representation of the current frame of the video feed.

this.webcam.captureScreenshot();

Alternatively, you can get a binary blob using captureBlob. This method takes in a callback with the resulting blob as its single argument.

this.webcam.captureBlob((blob) => {
  // ...
});

See the examples folder for more in-depth examples.

Props

PropTypeDefault
audiobooltrue
videobooltrue
widthnumber640
heightnumber480
captureFormatstring"image/png"
onSuccessfunc() => {}
onFailurefunc(error) => { throw error }
0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago