The Media Session of a browser for the episode that plays: what the lock screen and the notification show, and what their buttons and those of the headphones do, as player events for library/step.
The functions are pure. With the session namespace of the play-nice
library, a player of the episode id in the media element audio wires
them up like this, with a step! that runs an event through library/step
and does its effects:
(session/metadata! (:metadata (library/playback @lib id)))
(session/actions!
(zipmap (media-session/actions @lib id)
(repeat (fn [details]
(run! step! (media-session/events
@lib id (.-currentTime audio)
details))))))
The next and previous buttons go where the listener's preference :track-buttons says, as profile/default-preferences has it.
The Media Session of a browser for the episode that plays: what the lock
screen and the notification show, and what their buttons and those of
the headphones do, as player events for library/step.
The functions are pure. With the session namespace of the play-nice
library, a player of the episode `id` in the media element `audio` wires
them up like this, with a step! that runs an event through library/step
and does its effects:
(session/metadata! (:metadata (library/playback @lib id)))
(session/actions!
(zipmap (media-session/actions @lib id)
(repeat (fn [details]
(run! step! (media-session/events
@lib id (.-currentTime audio)
details))))))
The next and previous buttons go where the listener's preference
:track-buttons says, as profile/default-preferences has it.(actions library id)(actions library id opts)The actions of the Media Session that do something for the episode id
of library, with the opts of library/playback: the seeks, and the
next and previous buttons, unless they go to chapters and the episode
has none.
The actions of the Media Session that do something for the episode `id` of `library`, with the `opts` of library/playback: the seeks, and the next and previous buttons, unless they go to chapters and the episode has none.
(events library id position details)(events library
id
position
{:keys [action seek-offset seek-time] :as details}
opts)The player events of library/step that the Media Session action of
details asks for, on the episode id of library at position
seconds, with the opts of library/playback. The details are those of
MediaSessionActionDetails as a map in kebab-case, with the action as a
keyword, e.g. {:action :seekto :seek-time 754}.
The first event reports the position, and the next one moves:
Another action gives no events.
The player events of library/step that the Media Session action of
`details` asks for, on the episode `id` of `library` at `position`
seconds, with the `opts` of library/playback. The details are those of
MediaSessionActionDetails as a map in kebab-case, with the action as a
keyword, e.g. {:action :seekto :seek-time 754}.
The first event reports the position, and the next one moves:
- a seek back or forward goes the :seek-offset of the details, or else
the amount that the listener prefers
- a seek to a time goes to its :seek-time
- the next and previous buttons go to chapters or episodes of the
queue, as the listener's :track-buttons say. The previous button
restarts the episode or chapter, but goes to the one before in its
first few seconds, and the next button does nothing after the last
chapter, unless the buttons go to the queue once no chapter is left.
Another action gives no events.The actions that move within the episode.
The actions that move within the episode.
The actions of the next and previous buttons.
The actions of the next and previous buttons.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |