diff options
| author | Joris | 2020-03-03 10:44:35 +0100 | 
|---|---|---|
| committer | Joris | 2020-03-03 10:44:35 +0100 | 
| commit | 5c636f11cdfed82634ee572645d765b704941b68 (patch) | |
| tree | 51e11a0cfbbab284985e98fcb558d2975209a9b2 /src/audio.ml | |
| parent | a2880850a78fc36e2612215c83cbdeac0c980a5b (diff) | |
Initialize views from JavaScript
Diffstat (limited to 'src/audio.ml')
| -rw-r--r-- | src/audio.ml | 21 | 
1 files changed, 21 insertions, 0 deletions
| diff --git a/src/audio.ml b/src/audio.ml index f7358a7..1446440 100644 --- a/src/audio.ml +++ b/src/audio.ml @@ -11,3 +11,24 @@ external setCurrentTime : audio -> int -> unit = "currentTime" [@@bs.set]  let playOrReplay audio =    let () = if currentTime audio > 0 then setCurrentTime audio 0 else () in    play audio + +(* Sounds *) + +let c3 = create "sounds/c3.mp3" + +let c4 = create "sounds/c4.mp3" + +let c5 = create "sounds/c5.mp3" + +(* Play from step *) + +let playFromStep (config: Config.config) (step : Step.state) = +  match step.step with +  | Step.Prepare when step.remaining == config.prepare -> +      playOrReplay c3 +  | Step.Work when step.remaining == config.work -> +      playOrReplay c5 +  | Step.Rest when step.remaining == config.rest -> +      playOrReplay c3 +  | Step.End -> playOrReplay c3 +  | _ -> if step.remaining <= 3 then playOrReplay c4 else () | 
