Liking cljdoc? Tell your friends :D

dk.simongray.play-nice.page.autoplay

The browser's autoplay policy, the wait for the click, tap or key press after which the page may play, and autoplay of a video while it's in view.

The policy and the wait take these opts:

  • :window, the window to ask and listen at instead of the page's, e.g. a stand-in in a test

Only Firefox has Autoplay Policy Detection, so elsewhere you find out by calling media/play!, which answers {:refused :not-allowed} where the browser won't play. play-when-allowed! plays then at the user's next click, tap or key press.

Chrome and WebKit on iOS pause a muted video with the autoplay attribute when it scrolls out of view, and play it again when it returns, but leave alone a video that the page plays itself. play-in-view! does the same for any video, in every engine, through media/play!:

(def stop!
  (play-in-view! hero #(swap! page assoc :hero %) {:threshold 0.5}))
The browser's autoplay policy, the wait for the click, tap or key press
after which the page may play, and autoplay of a video while it's in
view.

The policy and the wait take these opts:

- :window, the window to ask and listen at instead of the page's, e.g.
  a stand-in in a test

Only Firefox has Autoplay Policy Detection, so elsewhere you find out by
calling media/play!, which answers {:refused :not-allowed} where the
browser won't play. play-when-allowed! plays then at the user's next
click, tap or key press.

Chrome and WebKit on iOS pause a muted video with the autoplay attribute
when it scrolls out of view, and play it again when it returns, but
leave alone a video that the page plays itself. play-in-view! does the
same for any video, in every engine, through media/play!:

    (def stop!
      (play-in-view! hero #(swap! page assoc :hero %) {:threshold 0.5}))
raw docstring

dk.simongray.play-nice.page.embed

The allow attribute of an iframe that embeds a player from another site, built from a map of the Permissions Policy features that the player may use.

Without the attribute, a player from another site can't go fullscreen, and its document reports document.fullscreenEnabled as false.

The allow attribute of an iframe that embeds a player from another site,
built from a map of the Permissions Policy features that the player may
use.

Without the attribute, a player from another site can't go fullscreen,
and its document reports document.fullscreenEnabled as false.
raw docstring

dk.simongray.play-nice.page.tabs

One playback across the tabs of an app, through Web Locks and a BroadcastChannel.

On a desktop, no engine stops the audio of one tab when another tab starts, so two tabs of a podcast app play at once and race to save the position. attach! holds a lock named for the app while the element plays, and takes it from any other tab that holds it, which then pauses its own element:

(def detach!
  (attach! audio "my-podcast-app"))

It also tells the other tabs what the element plays, where it is and whether it plays, so that the player of every tab can show the same playback, and it runs the actions that they send while it plays:

  • watch! gives a tab the newest playback across the tabs
  • position gives where a playback is by now
  • press! sends an action to the tab that plays
  • share! tells the other tabs of a change of a paused element
  • align! moves a paused element to the newest playback

The functions take these opts:

  • :window, the window whose navigator holds the locks, and whose BroadcastChannel reaches the other tabs, instead of the page's, e.g. a stand-in in a test
One playback across the tabs of an app, through Web Locks and a
BroadcastChannel.

On a desktop, no engine stops the audio of one tab when another tab
starts, so two tabs of a podcast app play at once and race to save the
position. attach! holds a lock named for the app while the element
plays, and takes it from any other tab that holds it, which then pauses
its own element:

    (def detach!
      (attach! audio "my-podcast-app"))

It also tells the other tabs what the element plays, where it is and
whether it plays, so that the player of every tab can show the same
playback, and it runs the actions that they send while it plays:

- watch! gives a tab the newest playback across the tabs
- position gives where a playback is by now
- press! sends an action to the tab that plays
- share! tells the other tabs of a change of a paused element
- align! moves a paused element to the newest playback

The functions take these opts:

- :window, the window whose navigator holds the locks, and whose
  BroadcastChannel reaches the other tabs, instead of the page's, e.g. a
  stand-in in a test
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close