I'm building an app where someone can record a video. The first part is just the preview stream which works great when the initially load the page. They tap the record button and it starts recording while still showing the preview. Once they're done recording they hit the stop button and then we no longer show the preview stream and instead give them the video they recorded. If they decide they don't like it and want to try again, we're clearing the blob url and we go back to the first step.
export default function RecordPage() {
const {
status,
startRecording,
stopRecording,
mediaBlobUrl,
previewStream,
clearBlobUrl,
error
} = useReactMediaRecorder({
video: true
});
console.log('status', status);
console.log('error', error);
console.log('mediaBlobUrl', mediaBlobUrl);
console.log('previewStream', previewStream);
if (status === "idle" || (status === "stopped" && !mediaBlobUrl)) {
return <Ready previewStream={previewStream} startRecording={startRecording} />;
} else if (status === "recording") {
return <Recording previewStream={previewStream} stopRecording={stopRecording} />;
} else if (status === "stopped" && mediaBlobUrl) {
return <DoneRecording mediaBlobUrl={mediaBlobUrl} clearBlobUrl={clearBlobUrl} />;
}
return <p>hello</p>;
}