How can I .requestFullscreen
(or .-volume
) on a video from another element ?
I've tried using this-as
macro and getElementByID
but my editor and Figwheel are unhappy when I try to make this function call.
How can I .requestFullscreen
(or .-volume
) on a video from another element ?
I've tried using this-as
macro and getElementByID
but my editor and Figwheel are unhappy when I try to make this function call.
Here is one way to do it:
(defn foo []
(let [v (atom nil)]
[:div
[:button
{:on-click
(fn [e]
(when @v
(cond
(.-requestFullscreen @v) (.requestFullscreen @v)
(.-mozRequestFullScreen @v) (.mozRequestFullScreen @v)
(.-webkitRequestFullScreen @v) (.webkitRequestFullscreen @v)
:else nil)))}
"Fullscreen"]
[:video
{:ref
(fn [elem]
(when elem
(reset! v elem)))
:src "https://archive.org/download/WebmVp8Vorbis/webmvp8.webm"}
"Sorry, your browser doesn't support embedded videos."]]))