import { Playback, TimerPhase, ViewSettings } from 'ontime-types'; import { millisToString } from 'ontime-utils'; import { useAuxTimersName, useAuxTimersTime, useStudioTimersSocket } from '../../common/hooks/useSocket'; import { getAuxTimerLabel } from '../../common/utils/auxTimerUtils'; import { getOffsetState } from '../../common/utils/offset'; import { cx } from '../../common/utils/styleUtils'; import { useTranslation } from '../../translation/TranslationProvider'; import { getPropertyValue } from '../common/viewUtils'; import { getTimerColour } from '../utils/presentation.utils'; import { useStudioOptions } from './studio.options'; import { getFormattedEventData, getFormattedScheduleTimes } from './studioTimers.utils'; import './StudioTimers.scss'; interface StudioTimersProps { viewSettings: ViewSettings; } export default function StudioTimers({ viewSettings }: StudioTimersProps) { const { getLocalizedString } = useTranslation(); const { mainSource } = useStudioOptions(); const { eventNow, eventNext, message, time, offset, rundown, expectedRundownEnd } = useStudioTimersSocket(); const schedule = getFormattedScheduleTimes({ offset: offset, actualStart: rundown.actualStart, expectedEnd: expectedRundownEnd, }); const event = getFormattedEventData(eventNow, time, mainSource); const eventNextTitle = getPropertyValue(eventNext, mainSource ?? 'title') || '-'; const formattedTimerMessage = (message.timer.visible && message.timer.text) || '-'; const formattedSecondaryMessage = message.timer.secondarySource === 'secondary' ? message.secondary || '-' : '-'; // gather presentation styles const timerColour = getTimerColour( viewSettings, undefined, time.phase === TimerPhase.Warning, time.phase === TimerPhase.Danger, ); const offsetState = getOffsetState(offset); return (
{getLocalizedString('common.started_at')}
{schedule.actualStart}
Over / under
{schedule.offset}
{getLocalizedString('common.expected_end')}
{schedule.expectedEnd}
{getLocalizedString('common.now')}
{event.title}
{getLocalizedString('common.next')}
{eventNextTitle}
{getLocalizedString('common.started_at')}
{event.startedAt}
{event.timer}
{getLocalizedString('common.expected_end')}
{event.expectedEnd}
{getLocalizedString('common.timer_message')}
{formattedTimerMessage}
{getLocalizedString('common.secondary_message')}
{formattedSecondaryMessage}
); } function StudioTimersAux() { const auxTimer = useAuxTimersTime(); const auxName = useAuxTimersName(); return (
{getAuxTimerLabel(auxName.aux1, 'Aux 1')}
{millisToString(auxTimer.aux1)}
{getAuxTimerLabel(auxName.aux2, 'Aux 2')}
{millisToString(auxTimer.aux2)}
{getAuxTimerLabel(auxName.aux3, 'Aux 3')}
{millisToString(auxTimer.aux3)}
); }