     (set! (.-onloadend reader)
       (fn []
         (swap! app-state assoc :current-sound
-          (.createSound js/soundManager #js {:id current-sound-id
+          (.createSound js/soundManager #js {:id track-id
                                              :type "audio/mpeg"
                                              :url (.-result reader)
                                              :autoLoad true}))
         (.play (:current-sound @app-state)
                #js {:whileplaying while-playing
                     :onfinish on-finish
-                    :onplay #(.setPosition js/soundManager current-sound-id
-                                                           position)})))))
+                    :onplay #(.setPosition (:current-sound @app-state)
+                                           position)})))))
 
 (.on socket "sign-in-success"
   (fn []


(.on socket "pause"
  (fn [position]
    (.pause js/soundManager current-sound-id)
    (.setPosition js/soundManager current-sound-id position)))

(.on socket "resume"
  (fn []
    (.resume js/soundManager current-sound-id)))

(.on socket "position-change"
  (fn [position]
    (letfn [(set-pos [position]
              (.setPosition js/soundManager current-sound-id position))]
      (println "Received pos: " position)
      (if (= 0 (.-playState (:current-sound @app-state)))
        (.play (:current-sound @app-state)


(defonce room-id (.getAttribute (. js/document (getElementById "roomid")) "data"))
(defonce socket (js/io))
(defonce default-upload-slots 4)
(defonce default-download-slots 4)
(defonce app-state (atom {:signed-in? false
