0

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.

Marcs
  • 3,768
  • 5
  • 33
  • 42
txesc
  • 21
  • 3
  • Sorry but "are unhappy" is quite a vague statement. Try to post the exception showed by figwheel. And I recommend using Lighttable as editor with figwheel for realtime editing, some info: http://stackoverflow.com/questions/37104853/how-to-automatically-reload-clojure-code/39440595#39440595. Also check [How to Ask](http://stackoverflow.com/help/how-to-ask) for some guidelines on how to ask a good question. – Marcs Sep 23 '16 at 14:17

1 Answers1

0

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."]]))
Timothy Pratley
  • 10,586
  • 3
  • 34
  • 63