import * as Config from 'config' import * as Step from 'step' 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, step: Step.Step, elapsed: number) { if (step.name === 'warmup' && step.remaining === config.warmup) { start.play() } else if (step.name === 'work' && step.remaining === config.work) { start.play() } else if (step.name === 'rest' && step.remaining === config.rest) { stop.play() } else if (step.name === 'prepare' && step.remaining === config.prepare && elapsed > 0) { endTabata.play() } else if (step.name === 'end' && elapsed === Config.getDuration(config)) { endTraining.play() } }