diff options
Diffstat (limited to 'src/audio.ts')
-rw-r--r-- | src/audio.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/audio.ts b/src/audio.ts index bdf64eb..4147164 100644 --- a/src/audio.ts +++ b/src/audio.ts @@ -7,13 +7,15 @@ const endTabata = new Audio('sound/end-tabata.mp3') const endTraining = new Audio('sound/end-training.mp3') export function playFromStep(config: Config.Config, state: State.State) { - if (state.step === State.Step.Work && state.remaining === config.work) { + if (state.step === State.Step.WarmUp && state.remaining === config.warmup) { + start.play() + } else if (state.step === State.Step.Work && state.remaining === config.work) { start.play() } else if (state.step === State.Step.Rest && state.remaining === config.rest) { stop.play() - } else if (state.step === State.Step.Prepare && state.remaining === config.prepare) { + } else if (state.step === State.Step.Prepare && state.remaining === config.prepare && state.elapsed > 0) { endTabata.play() - } else if (state.step === State.Step.End) { + } else if (state.step === State.Step.End && state.elapsed === Config.getDuration(config)) { endTraining.play() } } |