-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmedia_player_private.clj
65 lines (46 loc) · 2.78 KB
/
media_player_private.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(ns chromex.ext.media-player-private
" * available since Chrome 36"
(:refer-clojure :only [defmacro defn apply declare meta let partial])
(:require [chromex.wrapgen :refer [gen-wrap-helper]]
[chromex.callgen :refer [gen-call-helper gen-tap-all-events-call]]))
(declare api-table)
(declare gen-call)
; -- events -----------------------------------------------------------------------------------------------------------------
;
; docs: https://github.com/binaryage/chromex/#tapping-events
(defmacro tap-on-next-track-events
"Notifies that the next track was requested.
Events will be put on the |channel| with signature [::on-next-track []].
Note: |args| will be passed as additional parameters into Chrome event's .addListener call."
([channel & args] (apply gen-call :event ::on-next-track &form channel args)))
(defmacro tap-on-prev-track-events
"Notifies that the previous tack was requested.
Events will be put on the |channel| with signature [::on-prev-track []].
Note: |args| will be passed as additional parameters into Chrome event's .addListener call."
([channel & args] (apply gen-call :event ::on-prev-track &form channel args)))
(defmacro tap-on-toggle-play-state-events
"Notifies that a play/pause toggle was requested.
Events will be put on the |channel| with signature [::on-toggle-play-state []].
Note: |args| will be passed as additional parameters into Chrome event's .addListener call."
([channel & args] (apply gen-call :event ::on-toggle-play-state &form channel args)))
; -- convenience ------------------------------------------------------------------------------------------------------------
(defmacro tap-all-events
"Taps all valid non-deprecated events in chromex.ext.media-player-private namespace."
[chan]
(gen-tap-all-events-call api-table (meta &form) chan))
; ---------------------------------------------------------------------------------------------------------------------------
; -- API TABLE --------------------------------------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------------------------------------------------
(def api-table
{:namespace "chrome.mediaPlayerPrivate",
:since "36",
:events
[{:id ::on-next-track, :name "onNextTrack"}
{:id ::on-prev-track, :name "onPrevTrack"}
{:id ::on-toggle-play-state, :name "onTogglePlayState"}]})
; -- helpers ----------------------------------------------------------------------------------------------------------------
; code generation for native API wrapper
(defmacro gen-wrap [kind item-id config & args]
(apply gen-wrap-helper api-table kind item-id config args))
; code generation for API call-site
(def gen-call (partial gen-call-helper api-table))