Przeglądaj źródła

Started on YouTube intergration

KrisVos130 9 lat temu
rodzic
commit
9e69d25d7a
3 zmienionych plików z 29 dodań i 16 usunięć
  1. 4 0
      app/app.css
  2. 22 16
      app/app.js
  3. 3 0
      app/templates/room.html

+ 4 - 0
app/app.css

@@ -387,3 +387,7 @@ footer a:hover{
         background-color: red;
     }
 }
+
+#player {
+    visibility: hidden;
+}

+ 22 - 16
app/app.js

@@ -132,21 +132,27 @@ if (Meteor.isClient) {
         function startSong() {
             if (currentSong !== undefined) {
                 if (_sound !== undefined)_sound.stop();
-                SC.stream("/tracks/" + currentSong.song.id + "/", function(sound){
-                    _sound = sound;
-                    sound._player._volume = 0.3;
-                    console.log(sound);
-                    sound.play();
-                    Session.set("title", currentSong.song.title || "Title");
-                    Session.set("artist", currentSong.song.artist || "Artist");
-                    Session.set("albumArt", currentSong.song.albumArt);
-                    Session.set("duration", currentSong.song.duration)
-                    $("#seeker-bar").css("transition", Session.get("duration") + "s")
-                    $("#seeker-bar").width(1400);
-                    setTimeout(function() { // HACK, otherwise seek doesn't work.
-                        sound._player.seek(getTimeElapsed());
-                    }, 500);
-                });
+                    if (currentSong.song.type === "soundcloud") {
+                        $("#player").attr("src", "")
+                        SC.stream("/tracks/" + currentSong.song.id + "/", function(sound){
+                        _sound = sound;
+                        sound._player._volume = 0.3;
+                        console.log(sound);
+                        sound.play();
+                        Session.set("title", currentSong.song.title || "Title");
+                        Session.set("artist", currentSong.song.artist || "Artist");
+                        Session.set("albumArt", currentSong.song.albumArt);
+                        Session.set("duration", currentSong.song.duration)
+                        $("#seeker-bar").css("transition", Session.get("duration") + "s")
+                        $("#seeker-bar").width(1400);
+                        setTimeout(function() { // HACK, otherwise seek doesn't work.
+                            sound._player.seek(getTimeElapsed());
+                        }, 500);
+                    });
+                } else {
+                    console.log("YT!");
+                    $("#player").attr("src", "http://www.youtube.com/embed/" + currentSong.song.id + "?autoplay=1&controls=0&autohide=1");
+                }
             }
         }
 
@@ -180,7 +186,7 @@ if (Meteor.isServer) {
     Meteor.users.deny({remove: function () { return true; }});
 
     var startedAt = Date.now();
-    var songs = [{id: 216112412, title: "How Deep Is Your Love", artist: "Calvin Harris", duration: 193}];
+    var songs = [{id: "jofNR_WkoCE", title: "The Fox", artist: "Ylvis", duration: 15, type: "youtube"}, {id: 216112412, title: "How Deep Is Your Love", artist: "Calvin Harris", duration: 193, type: "soundcloud"}];
     var currentSong = 0;
     addToHistory(songs[currentSong], startedAt);
 

+ 3 - 0
app/templates/room.html

@@ -4,6 +4,9 @@
         <h2 class="room-title">{{{title}}}</h2>
         <h2 class="room-artist">{{{artist}}}</h2>
         <div id="seeker-bar"></div>
+        <!--src="http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=1&controls=0&autohide=1">-->
+        <iframe width="960" height="540" id="player">
+        </iframe>
         <ul class="bg-bubbles">
             <li></li>
             <li></li>