Fork me on GitHub
#rum
<
2017-03-15
>
grounded_sage00:03:09

@misha that code you shared worked perfectly. It's actually more than I needed haha. Thanks heaps.

grounded_sage01:03:12

This is more like the code I am trying to do. But this in it's current form doesn't work. I'm putting it down to me not understanding :init

(rum/defcs video
  < {:init
     (fn [state _]
       (let [video (atom nil)]
            #?(:cljs (gob/set @video "playbackRate" 0.6))
         (assoc state
           :video video)))}

  [state]
  (let [set-ref!  (:video state)]
    [:div {:class ["full-width"
                   (css {:height 0})]}
     [:div.inside-block
      [:div
        [:video#my-video.video {:auto-play "autoplay"
                                :loop "loop"
                                :muted true
                                :width "300"
                                :height "150"
                                :ref set-ref!
                                :controls true}

         [:source {:src "media/demo.mp4"
                   :type "video/mp4"}]
         [:source {:src "media/demo.webm"
                   :type "video/webm"}]]]]]))

grounded_sage02:03:14

What I'm doing is rendering everything statically serverside and then turning it into a SPA client side. Which is why I have the :cljs conditional in there. I'm simply trying to set the playbackRate o a background video. In hindsight this is probably best done in a video editor because it seems the complications around doing it in code is more time consuming 😛

misha02:03:10

set-ref!  #(reset! (:video state) %)
not
set-ref!  (:video state)

misha03:03:09

also try to set rate to 0.6 when video ref atom value changes from nil to node

grounded_sage03:03:14

I'm not quite sure what you mean when you say from nil to node. Is that inside the (when-let [node @video] ...??

grounded_sage03:03:53

so I would do something like :ref (set-ref! 0.6)

grounded_sage03:03:47

no that wouldn't work xD

mruzekw19:03:27

Is there a way to set the initial state of a rum/local atom via an incoming prop/rum arg?

mruzekw19:03:59

I would do it in :will-mount but the value could be nil and doesn’t update after that

mruzekw19:03:40

I guess I could do it on :will-update, see if the rum/local has been set

mruzekw19:03:13

The only issue is it won’t receive subsequent updates. Which is sort of what I want, and in this case not problematic