Picture-in-Picture of a video: whether it's available, entering and leaving it, and the size of its window, as data.
Each engine refuses a video in its own words, e.g. a video with disablePictureInPicture throws an InvalidStateError in Chrome and Firefox, but a NotSupportedError in WebKit. So enter! checks the video first, and answers with one keyword for each cause:
(-> (enter! video)
(.then prn))
;; prints {:picture-in-picture true :width 320 :height 180}, or e.g.
;; {:refused :not-allowed}
To keep track of whether the video is in Picture-in-Picture, use watch!, which also sees the user close the window.
Picture-in-Picture of a video: whether it's available, entering and
leaving it, and the size of its window, as data.
Each engine refuses a video in its own words, e.g. a video with
disablePictureInPicture throws an InvalidStateError in Chrome and
Firefox, but a NotSupportedError in WebKit. So enter! checks the video
first, and answers with one keyword for each cause:
(-> (enter! video)
(.then prn))
;; prints {:picture-in-picture true :width 320 :height 180}, or e.g.
;; {:refused :not-allowed}
To keep track of whether the video is in Picture-in-Picture, use
watch!, which also sees the user close the window.(available? video)Whether the video can enter Picture-in-Picture: the browser has it,
the page may use it, and the video has a video track and doesn't
disable it. A video without its metadata yet counts as available.
Whether the `video` can enter Picture-in-Picture: the browser has it, the page may use it, and the video has a video track and doesn't disable it. A video without its metadata yet counts as available.
(enter! video)Show the video in Picture-in-Picture, and return a promise of the
answer, which never rejects:
Call it in a click handler, since Chrome and WebKit refuse it otherwise. A video without its metadata yet enters once it has loaded it, as long as the click still counts, e.g. for 5 seconds in Chrome.
Show the `video` in Picture-in-Picture, and return a promise of the
answer, which never rejects:
- its state, as watch! passes it, with the size of the window, e.g.
{:picture-in-picture true :width 320 :height 180}
- {:refused :not-allowed} without a click, or where the page may not
- {:refused :not-supported} where the browser has no Picture-in-Picture
for it, e.g. for an audio element
- {:refused :disabled} for a video with disablePictureInPicture
- {:refused :no-video} for a video without a video track
Call it in a click handler, since Chrome and WebKit refuse it otherwise.
A video without its metadata yet enters once it has loaded it, as long
as the click still counts, e.g. for 5 seconds in Chrome.(exit! video)Take the video out of Picture-in-Picture, if it's in it, and return a
promise of {:picture-in-picture false}, which never rejects.
Take the `video` out of Picture-in-Picture, if it's in it, and return a
promise of {:picture-in-picture false}, which never rejects.(state video)The Picture-in-Picture state of the video now, e.g.
{:picture-in-picture true}. Only watch! knows the size of the window.
The Picture-in-Picture state of the `video` now, e.g.
{:picture-in-picture true}. Only watch! knows the size of the window.(watch! video f)Call f with the Picture-in-Picture state of the video now and at
each enter, resize and leave, and return a function that stops it. The
state is {:picture-in-picture true :width 320 :height 180} while it's in
Picture-in-Picture, and {:picture-in-picture false} otherwise.
The size comes from the window at each enter and resize, so a video in Picture-in-Picture before the call has none until its window resizes. Firefox leaves only after the promise of exit! has resolved.
Call `f` with the Picture-in-Picture state of the `video` now and at
each enter, resize and leave, and return a function that stops it. The
state is {:picture-in-picture true :width 320 :height 180} while it's in
Picture-in-Picture, and {:picture-in-picture false} otherwise.
The size comes from the window at each enter and resize, so a video in
Picture-in-Picture before the call has none until its window resizes.
Firefox leaves only after the promise of exit! has resolved.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 |