aboutsummaryrefslogtreecommitdiff
path: root/src/audio.ts
blob: bdf64eb56ec0e473cf412b57cb57108956a0a4b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()
  }
}