From 25afb0bde9b8a2c064135a534231c232a461b341 Mon Sep 17 00:00:00 2001
From: Joris
Date: Sun, 16 Feb 2020 22:45:07 +0100
Subject: Set up a first version of tabata timer

---
 src/audio.ml | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 src/audio.ml

(limited to 'src/audio.ml')

diff --git a/src/audio.ml b/src/audio.ml
new file mode 100644
index 0000000..f7358a7
--- /dev/null
+++ b/src/audio.ml
@@ -0,0 +1,13 @@
+type audio
+
+external create : string -> audio = "Audio" [@@bs.new]
+
+external play : audio -> unit = "play" [@@bs.send]
+
+external currentTime : audio -> int = "currentTime" [@@bs.get]
+
+external setCurrentTime : audio -> int -> unit = "currentTime" [@@bs.set]
+
+let playOrReplay audio =
+  let () = if currentTime audio > 0 then setCurrentTime audio 0 else () in
+  play audio
-- 
cgit v1.2.3