npm i react-media-recorder
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import { ReactMediaRecorder } from "react-media-recorder"; const App = () => ( <div> <ReactMediaRecorder video render={({ status, startRecording, stopRecording, mediaBlobUrl }) => ( <div> <p>{status}</p> <button onClick={startRecording}>Start Recording</button> <button onClick={stopRecording}>Stop Recording</button> <video src={mediaBlobUrl} controls autoPlay loop /> </div> )} /> </div> ); export default App |
Here you can pass three options for video,audio and screen
recording
video
audio
screen
Usage with react hooks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import { useReactMediaRecorder } from "react-media-recorder"; const RecordView = () => { const { status, startRecording, stopRecording, mediaBlobUrl, } = useReactMediaRecorder({ video: true }); return ( <div> <p>{status}</p> <button onClick={startRecording}>Start Recording</button> <button onClick={stopRecording}>Stop Recording</button> <video src={mediaBlobUrl} controls autoPlay loop /> </div> ); }; |