mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 05:13:32 +00:00
Feat resumability (#547)
* add resumability functionality --------- Co-authored-by: arc-alex <ac@omnivox.dk> Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
b34fe71995
commit
a84c0654e2
@@ -1,4 +1,4 @@
|
||||
import { LogOrigin, OntimeEvent } from 'ontime-types';
|
||||
import { LogOrigin, OntimeEvent, Playback } from 'ontime-types';
|
||||
import { validatePlayback } from 'ontime-utils';
|
||||
|
||||
import { eventLoader, EventLoader } from '../classes/event-loader/EventLoader.js';
|
||||
@@ -6,6 +6,7 @@ import { eventStore } from '../stores/EventStore.js';
|
||||
import { eventTimer } from './TimerService.js';
|
||||
import { clock } from './Clock.js';
|
||||
import { logger } from '../classes/Logger.js';
|
||||
import { RestorePoint } from './RestoreService.js';
|
||||
|
||||
/**
|
||||
* Service manages playback status of app
|
||||
@@ -241,6 +242,33 @@ export class PlaybackService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description resume playback state given a restore point
|
||||
* @param restorePoint
|
||||
*/
|
||||
static resume(restorePoint: RestorePoint) {
|
||||
const willResume = () => logger.info(LogOrigin.Server, 'Resuming playback');
|
||||
|
||||
if (restorePoint.playback === Playback.Roll) {
|
||||
willResume();
|
||||
PlaybackService.roll();
|
||||
}
|
||||
|
||||
if (restorePoint.selectedEventId) {
|
||||
const event = EventLoader.getEventWithId(restorePoint.selectedEventId);
|
||||
// the db would have to change for the event not to exist
|
||||
// we do not kow the reason for the crash, so we check anyway
|
||||
if (!event) {
|
||||
return;
|
||||
}
|
||||
|
||||
eventLoader.loadEvent(event);
|
||||
eventTimer.resume(event, restorePoint);
|
||||
eventStore.broadcast();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds delay to current event
|
||||
* @param {number} delayTime time in minutes
|
||||
|
||||
Reference in New Issue
Block a user