Updated handleRecordingStarted and fixed typo

This commit is contained in:
Kimberlee Johnson 2021-11-29 16:01:00 -08:00
parent 16d259ccc4
commit d270fd3d34
2 changed files with 14 additions and 2 deletions

View File

@ -94,7 +94,7 @@ export const RecordingModal = () => {
{!enableRecording ? (
<Well variant="error">
Recording is not enabled for this room (or your browser does not
support it.) Please enabled recording when creating the room or via
support it.) Please enable recording when creating the room or via
the Daily dashboard.
</Well>
) : (

View File

@ -177,13 +177,25 @@ export const RecordingProvider = ({ children }) => {
*/
const handleRecordingStarted = useCallback(
(event) => {
console.log('RECORDING');
console.log(event);
if (recordingState === RECORDING_RECORDING) return;
setRecordingState(RECORDING_RECORDING);
if (event.local) {
// Recording started locally, either through UI or programmatically
setIsRecordingLocally(true);
if (!recordingStartedDate) setRecordingStartedDate(new Date());
if (event.type === 'output-byte-stream') {
const { readable, writable } = new TransformStream({
transform: (chunk, ctrl) => {
chunk.arrayBuffer().then((b) => ctrl.enqueue(new Uint8Array(b)));
},
});
window.writer = writable.getWriter();
readable.pipeTo(window.streamSaver.createWriteStream('test-vid.mp4'));
}
}
setRecordingState(RECORDING_RECORDING);
},
[recordingState, recordingStartedDate]
);