Record RTC for ReactJS
npm install react-rrtcreact-rrtc is a ReactJS plugin that provides a convenient hook for recording audio and video
streams using the RecordRTC library. This plugin simplifies the process of
recording media streams
within your React applications.
- Record audio, screen and video streams with ease.
- Pause and resume recording functionality.
- Access to recorded media as Blob objects.
- Compatibility with various media stream configurations.
- Flexibility to customize recording options.
To install react-rrtc, simply run:
``bash`
npm install react-rrtc
or
`bash`
yarn add react-rrtc
`javascript`
import {useRecordRTC} from "react-rrtc";
`jsx
import React from 'react';
import {useRecordRTC} from 'react-rrtc';
const MyComponent = () => {
const [timerStatus, setTimerStatus] = React.useState(false);
const options = {
countDownSec: 5, // Optional: Countdown before recording starts in seconds
rtcOptions: {}, // Optional: Additional options for RecordRTC
afterRecordingStartHook: async () => {
setTimerStatus(false);
},
};
const {
blob,
recorder,
recorderState,
previewVideoRef,
audioPreviewRef,
getScreenStream,
getUserMediaStream,
startRecording,
pauseRecording,
resumeRecording,
stopRecording,
} = useRecordRTC(options);
// Your component logic here
return (
export default MyComponent;
`
- blob: The recorded media as a Blob object.recorder
- : The RecordRTCPromisesHandler instance.recorderState
- : The current state of the recorder (e.g., "inactive", "recording", "paused").previewVideoRef
- : Ref for previewing video.audioPreviewRef
- : Ref for previewing audio.
- getScreenStream(constraints: DisplayMediaStreamOptions): Promise: Get a mediagetUserMediaStream(constraints: MediaStreamConstraints): Promise
stream from the screen.
- : Get a user mediastartRecording(stream: MediaStream, type: "audio"|"video" = "audio"): Promise
stream.
- : StartpauseRecording(): Promise
recording from a media stream.
- : Pause the current recording.resumeRecording(): Promise
- : Resume a paused recording.stopRecording(): Promise
-
And many more to come...
This project is licensed under the MIT License - see the LICENSE file for details.