ClojureScript在视频上使用.requestFullscreen

时间:2016-09-23 00:54:59

标签: html5-video clojurescript reagent

我如何.requestFullscreen(或.-volume)来自其他元素的视频?

我尝试使用this-as宏和getElementByID,但是当我尝试调用此函数时,我的编辑器和Figwheel不满意。

1 个答案:

答案 0 :(得分:0)

这是一种方法:

(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."]]))