import React, { useEffect } from 'react'; import Button from '@custom/shared/components/Button'; import { CardBody } from '@custom/shared/components/Card'; import Modal from '@custom/shared/components/Modal'; import Well from '@custom/shared/components/Well'; import { useCallState } from '@custom/shared/contexts/CallProvider'; import { useUIState } from '@custom/shared/contexts/UIStateProvider'; import { RECORDING_COUNTDOWN_1, RECORDING_COUNTDOWN_2, RECORDING_COUNTDOWN_3, RECORDING_IDLE, RECORDING_RECORDING, RECORDING_SAVED, RECORDING_TYPE_CLOUD, RECORDING_TYPE_CLOUD_BETA, RECORDING_TYPE_RTP_TRACKS, RECORDING_UPLOADING, useRecording, } from '../contexts/RecordingProvider'; export const RECORDING_MODAL = 'recording'; export const RecordingModal = () => { const { currentModals, closeModal } = useUIState(); const { enableRecording } = useCallState(); const { recordingStartedDate, recordingState, startRecordingWithCountdown, stopRecording, } = useRecording(); useEffect(() => { if (recordingState === RECORDING_RECORDING) { closeModal(RECORDING_MODAL); } }, [recordingState, closeModal]); const disabled = enableRecording && [RECORDING_IDLE, RECORDING_RECORDING].includes(recordingState); function renderButtonLabel() { if (!enableRecording) { return 'Recording disabled'; } switch (recordingState) { case RECORDING_COUNTDOWN_3: return '3...'; case RECORDING_COUNTDOWN_2: return '2...'; case RECORDING_COUNTDOWN_1: return '1...'; case RECORDING_RECORDING: return 'Stop recording'; case RECORDING_UPLOADING: case RECORDING_SAVED: return 'Stopping recording...'; default: return 'Start recording'; } } function handleRecordingClick() { if (recordingState === RECORDING_IDLE) { startRecordingWithCountdown(); } else { stopRecording(); } } return ( closeModal(RECORDING_MODAL)} actions={[ , , ]} > {!enableRecording ? ( Recording is not enabled for this room (or your browser does not support it.) Please enabled recording when creating the room or via the Daily dashboard. ) : (

Recording type enabled: {enableRecording}

)} {recordingStartedDate && (

Recording started: {recordingStartedDate.toString()}

)} {[RECORDING_TYPE_CLOUD, RECORDING_TYPE_CLOUD_BETA].includes( enableRecording ) && ( <>

Cloud recordings can be accessed via the Daily dashboard under the "Recordings" section.

)} {enableRecording === RECORDING_TYPE_RTP_TRACKS && ( <>

rtp-tracks recordings can be accessed via the Daily API. See the{' '} Daily recording guide {' '} for details.

)}
); }; export default RecordingModal;