extract isPlaybackActive to a global util function (#1393)

This commit is contained in:
Alex Christoffer Rasmussen
2024-12-18 12:44:48 +01:00
committed by GitHub
parent df1cf7a96b
commit cfcf6a5684
5 changed files with 25 additions and 19 deletions
+3 -16
View File
@@ -1,5 +1,5 @@
import { MaybeNumber, Playback, TimerPhase } from 'ontime-types';
import { dayInMs } from 'ontime-utils';
import { MaybeNumber, TimerPhase } from 'ontime-types';
import { dayInMs, isPlaybackActive } from 'ontime-utils';
import { RuntimeState } from '../stores/runtimeState.js';
/**
@@ -187,25 +187,12 @@ export function getExpectedEnd(state: RuntimeState): MaybeNumber {
return state.runtime.plannedEnd - state.runtime.offset + state._timer.totalDelay;
}
/**
* Utility checks whether the playback is considered to be active
* @param state
* @returns
*/
export function isPlaybackActive(state: RuntimeState): boolean {
return (
state.timer.playback === Playback.Play ||
state.timer.playback === Playback.Pause ||
state.timer.playback === Playback.Roll
);
}
/**
* Checks running timer to see which phase it currently is in
* @param state
*/
export function getTimerPhase(state: RuntimeState): TimerPhase {
if (!isPlaybackActive(state)) {
if (!isPlaybackActive(state.timer.playback)) {
return TimerPhase.None;
}