https://github.com/bsonntag/react-user-media
A react component that wraps `getUserMedia`.
https://github.com/bsonntag/react-user-media
componets getusermedia mediastream react
Last synced: about 1 year ago
JSON representation
A react component that wraps `getUserMedia`.
- Host: GitHub
- URL: https://github.com/bsonntag/react-user-media
- Owner: bsonntag
- License: mit
- Created: 2018-06-24T00:06:58.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-09-11T21:14:18.000Z (almost 2 years ago)
- Last Synced: 2025-03-25T05:51:17.383Z (over 1 year ago)
- Topics: componets, getusermedia, mediastream, react
- Language: JavaScript
- Size: 1.96 MB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @bsonntag/react-user-media
> A react component that wraps `getUserMedia`.
## Installation
Using npm:
```sh
$ npm install --save @bsonntag/react-user-media
```
Using yarn:
```sh
$ yarn add @bsonntag/react-user-media
```
This module uses react's `createContext` API,
so make sure you have at least version 16.3.0 installed.
## Example usage
```js
import UserMedia from '@bsonntag/react-user-media';
import React from 'react';
const constraints = { video: true };
const App = () => (
{stream => (
)}
);
```
## Props
- `children` - A function that receives the `MediaStream` and renders something.
- `constraints` - A [`MediaStreamConstraints`](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints).
- `onError` - A function that is called when `getUserMedia` throws.
- `onMediaStream` - A function that receives the `MediaStream`.
- `placeholder` - An element that is rendered while `getUserMedia` is being called.
- `renderError` - A function that receives the error thrown by `getUserMedia` and renders something.
## Contributing
Please feel free to submit any issues or pull requests.
## License
MIT