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
2020-07-10 06:36:57 +01:00
committed by GitHub
parent 5d9035dcaf
commit 43001ccbbd

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);
}