       (.emit (js/ss socket) "file" stream)
       (.pipe blob-stream stream))))
 
+(.bind (js/$ "#audio-tag") "ended"
+  (fn []
+    (println "Track ended!")))

                          :music-files {}
                          :message-received false
                          :file-downloading? false
                          :num-of-queued-requests 0}))

(enable-console-print!)


        (let [reader (new js/FileReader)
              blob   (get (:music-files @app-state) (.-id stream))]
          (.readAsDataURL reader blob)
          (if-not (is-music-playing?)
          (set! (.-onloadend reader)
            (fn []
                (request-new-file)
                (swap! app-state assoc :file-downloading? false)
                (.attr (js/$ "#current-track") "src" (.-result reader))
                (.load (.getElementById js/document "audio-tag"))
                (.play (.getElementById js/document "audio-tag"))
                (println (str "Number of music files downloaded "
                              (count (:music-files @app-state))))))))))))

(.change (js/$ "#file_upload_input")
  (fn [e]
