From 221b6451fb4f8559a10e7fefebd13ce125ef29d0 Mon Sep 17 00:00:00 2001 From: Joris Date: Thu, 13 May 2021 14:50:51 +0200 Subject: Rewrite in TypeScript BuckleScript is no longer maintained. Choose a widely used techno that will still be maintained in the following years. --- src/audio.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/audio.ts (limited to 'src/audio.ts') diff --git a/src/audio.ts b/src/audio.ts new file mode 100644 index 0000000..bdf64eb --- /dev/null +++ b/src/audio.ts @@ -0,0 +1,19 @@ +import * as Config from 'config' +import * as State from 'state' + +const start = new Audio('sound/start.mp3') +const stop = new Audio('sound/stop.mp3') +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) { + 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) { + endTabata.play() + } else if (state.step === State.Step.End) { + endTraining.play() + } +} -- cgit v1.2.3