Now supports React@16!
react-multimedia capture is module for capturing multimedia from WebBrowser via React. It uses navigator.mediaDevices.getUserMedia and MediaRecorder API, so make sure that your browser supports.
- Uses supporting getUserMedia API from mediaDevices.getUserMedia/getUserMedia/-vendor_prefix-GetUserMedia.
- Easy, intuitive interface
- Video Recording
- Audio Recording
- Supports Pausing & Resuming
Example can found from here: react-multimedia-capture-example. Example demonstrates all features in react-multimedia-capture.
import MediaCapturer from 'react-multimedia-capture';
class VideoExample extends Component {
...
render() {
return (
<div>
...
<h1>Video Recording Example</h1>
<hr />
<MediaCapturer
constraints={{ audio: true, video: true }}
timeSlice={10}
onGranted={this.handleGranted}
onDenied={this.handleDenied}
onStart={this.handleStart}
onStop={this.handleStop}
onPause={this.handlePause}
onResume={this.handleResume}
onError={this.handleError}
onStreamClosed={this.handleStreamClose}
render={({ request, start, stop, pause, resume }) =>
<div>
<p>Granted: {granted.toString()}</p>
<p>Rejected Reason: {rejectedReason}</p>
<p>Recording: {recording.toString()}</p>
<p>Paused: {paused.toString()}</p>
{!granted && <button onClick={request}>Get Permission</button>}
<button onClick={start}>Start</button>
<button onClick={stop}>Stop</button>
<button onClick={pause}>Pause</button>
<button onClick={resume}>Resume</button>
<p>Streaming test</p>
<video autoPlay></video>
</div>
} />
</div>
);
}
}
Set the getUserMedia constraints. Default is { video: true, audio: true }.
Set the class name of the element.
Set mimeType for MediaRecorder API. It uses 'video/webm;codecs=vp8' by default. If you are trying to record Audio, you should use 'audio/webm' instead.
Set time slice of mediaRecorder.start.
Handler that fires on browser acquired permission to access media devices. From @1.2.1, MediaStream passing through first argument.
Handler that fires on browser denied permission to access media devices.
Handler that fires on user started recording.
Handler that fires on user stopped recording. This method will stop MediaStream, but if you want to stay alive, set stopStream to false.
Handler that fires on user paused recording.
Handler that fires on user resumed recording.
Handler that fires on error occurs. This also could be fired if the browser not support getUserMedia and mediaRecorder API.
Handler that fires when stream is closed. This happens when you stop the record. After stopped record, you can't start record before get permission again to get new MediaStream to work.
Render the child components with functions. Each function actually manipulate recording related jobs into parent like VideoRecorder or AudioRecorder.
- request: Function to get permission of recording media.
- start: Function to start recording.
- stop: Function to stop recording.
- pause: Function to pause recording.
- resume: Function to resume recording.
- Added stop recording on unmounting component
- Fixed event typo in ondataavailable
- Fixed "Cannot find module" issue using with Webpack
- Passing MediaStream to onGranted props.
- Fixed Stop recording doesn't work anymore
- Added functionality to request permission after stop recording
- Updated Stop method to decide stop MediaStream or not.
- Updated to support changing camera.