Ensure api method .play() can be called by external code without worrying about the internal state of the finite state machine (#236)

This commit is contained in:
Eoghan Murray
2026-04-01 12:00:00 +08:00
committed by GitHub
parent dacaf57b0e
commit 7d7def23d1

View File

@@ -178,7 +178,14 @@ export class Replayer {
* @param timeOffset number
*/
public play(timeOffset = 0) {
this.service.send({ type: 'PLAY', payload: { timeOffset } });
if (this.service.state.value == 'ended') {
this.service.send({ type: 'REPLAY'});
}
if (this.service.state.value == 'paused') {
this.service.send({ type: 'RESUME', payload: { timeOffset } });
} else {
this.service.send({ type: 'PLAY', payload: { timeOffset } });
}
this.emitter.emit(ReplayerEvents.Start);
}