1(import [threading [Semaphore]]
2 [mpv.util [temp-event]]
3 [protocol [commands]])
4(require [hy.contrib.walk [let]])
5
6(with-decorator (commands.add "pause")
7 (defn pause [mpv cmd]
8 (mpv.set-property "pause"
9 (or (not cmd) (first cmd)))
10 None))
11
12(with-decorator (commands.add "play")
13 (defn play [mpv cmd]
14 (when cmd
15 (let [lock (Semaphore 0)
16 handler (fn [_] (lock.release))]
17 (with [(temp-event mpv "file-loaded" handler)]
18 (mpv.set-property "playlist-pos" (first cmd))
19 (lock.acquire))))
20 (mpv.set-property "pause" False)))