       (>! msg-ch (m/->SetPlaying false))
       stopped-at)))
 
-(defn start-event-loop!
+(defn start-event-loop
   "Main event loop of the Recording."
-  [{:keys [recording-ch-fn start-at speed loop?] :as source} command-ch msg-ch]
+  [{:keys [start-at speed loop? command-ch]} msg-ch data]
   (let [pri-ch (chan 10)]
     (go-loop [start-at start-at
               speed speed

                       (deliver (recording-fn res))))))))

(defn report-metadata
  "Waits for recording to load and then reports its size and duration to the
  player."
  [{:keys [recording-ch-fn]} msg-ch]
  (go
    (let [{:keys [duration width height]} (<! (@recording-ch-fn false))]
      (>! msg-ch (m/->SetMetadata width height duration))
      (>! msg-ch (m/->TriggerCanPlay)))))

(defn show-poster
  "Forces loading of recording and sends 'poster' at a given time to the
  player."
  [{:keys [recording-ch-fn]} time msg-ch]
  (go
    (let [{:keys [frames]} (<! (@recording-ch-fn true))]
      (>! msg-ch (m/->UpdateScreen (screen-at time frames))))))

(defn show-loading
  "Reports 'loading' to the player until the recording is loaded."
  [{:keys [recording-ch-fn]} msg-ch]
  (when-not (poll! (@recording-ch-fn false))
    (go
      (>! msg-ch (m/->SetLoading true))
      (<! (@recording-ch-fn false))
      (>! msg-ch (m/->SetLoading false)))))

(defn emit-coll
  "Starts sending frames as events with a given name, stopping when out-ch

                                                        js/JSON.parse
                                                        (js->clj :keywordize-keys true)
                                                        initialize-asciicast)))
        command-ch (chan 10)
        force-load-ch (chan)]
    (->Recording recording-ch-fn
                 command-ch
                 force-load-ch
                 start-at
                 speed
                 auto-play
