diff options
author | Joris | 2021-05-15 12:47:04 +0200 |
---|---|---|
committer | Joris | 2021-05-15 12:47:04 +0200 |
commit | d1ce8774ec3291374c222c8f64c085e3a99f6147 (patch) | |
tree | 3ed888c65600cfea0d56494ae35940744eba1d14 /src/audio.ts | |
parent | 6a9f9a9f3cf547da80df973950489e343143289d (diff) |
Add warm up
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() } } |