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.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 && state.elapsed > 0) { endTabata.play() } else if (state.step === State.Step.End && state.elapsed === Config.getDuration(config)) { endTraining.play() } }