Browse Source

minor updates

unknown 9 years ago
parent
commit
6b06b8466b
3 changed files with 30 additions and 11 deletions
  1. 2 3
      app/app.css
  2. 27 7
      app/app.js
  3. 1 1
      app/templates/room.html

+ 2 - 3
app/app.css

@@ -452,11 +452,10 @@ footer a:hover{
 .footerButtons:hover {
   background-color: #f5f7f9;
 }
-#albumart{
-  width: 170px;
+.current{
+  width: 210px;
   margin-left: 35px;
 }
-
 #seeker-container {
     width: calc(100% - 70px);
     margin-left: 35px;

+ 27 - 7
app/app.js

@@ -211,7 +211,7 @@ if (Meteor.isClient) {
             return 0;
         }
 
-        function getSongInfo(query, type){
+        function getSongInfo(query, platform){
           var search = query;
           var titles = [];
           query = query.toLowerCase().split(" ").join("%20");
@@ -229,7 +229,7 @@ if (Meteor.isClient) {
                       var info = data[i].items[j];
                       Session.set("title", data[i].items[j].name);
                       console.log("Info: " + info);
-                      if(type === "youtube"){
+                      if(platform === "youtube"){
                         Session.set("duration", data[i].items[j].duration_ms / 1000)
                         console.log(Session.get("duration"));
                       }
@@ -249,8 +249,8 @@ if (Meteor.isClient) {
                         artistStr = temp;
                       }
                       Session.set("artist", artistStr);
-                      $("#albumart").remove();
-                      $(".room-title").before("<img id='albumart' src='" + data[i].items[j].album.images[1].url + "' />")
+                      $(".current").remove();
+                      $(".room-title").before("<img class='current' src='" + data[i].items[j].album.images[1].url + "' />");
                       return true;
                     }
                   }
@@ -394,7 +394,24 @@ if (Meteor.isServer) {
                 }
             }
         }
-      }
+    }
+
+    function getSongAlbumArt(query){
+        var albumart;
+        var search = query;
+        query = query.toLowerCase().split(" ").join("%20");
+
+        var res = Meteor.http.get('https://api.spotify.com/v1/search?q=' + query + '&type=track');
+
+        for(var i in res.data){
+            for(var j in res.data[i].items){
+                if(search.indexOf(res.data[i].items[j].name) !== -1){
+                    albumart = res.data[i].items[j].album.images[1].url
+                    return albumart;
+                }
+            }
+        }
+    }
 
     var room_types = ["edm", "nightcore"];
     var songsArr = [];
@@ -403,9 +420,12 @@ if (Meteor.isServer) {
     room_types.forEach(function(type) {
         if (Playlists.find({type: type}).fetch().length === 0) {
             if (type === "edm") {
-                Playlists.insert({type: type, songs: [{id: "aE2GCa-_nyU", title: "Radioactive - Lindsey Stirling and Pentatonix", duration: getSongDuration("Radioactive - Lindsey Stirling and Pentatonix"), type: "youtube"}, {id: "aHjpOzsQ9YI", title: "Crystallize", artist: "Linsdey Stirling", duration: getSongDuration("Crystallize"), type: "youtube"}]});
+                Playlists.insert({type: type, songs: [
+                  {id: "aE2GCa-_nyU", title: "Radioactive - Lindsey Stirling and Pentatonix", duration: getSongDuration("Radioactive - Lindsey Stirling and Pentatonix"), albumart: getSongAlbumArt("Radioactive - Lindsey Stirling and Pentatonix"), type: "youtube"},
+                  {id: "aHjpOzsQ9YI", title: "Crystallize", artist: "Linsdey Stirling", duration: getSongDuration("Crystallize"), albumart: getSongAlbumArt("Crystallize"), type: "youtube"}
+                ]});
             } else if (type === "nightcore") {
-                Playlists.insert({type: type, songs: [{id: "f7RKOP87tt4", title: "Monster (DotEXE Remix)", duration: getSongDuration("Monster (DotEXE Remix)") , type: "youtube"}]});
+                Playlists.insert({type: type, songs: [{id: "f7RKOP87tt4", title: "Monster (DotEXE Remix)", duration: getSongDuration("Monster (DotEXE Remix)"), albumart: getSongAlbumArt("Monster (DotEXE Remix)"), type: "youtube"}]});
             }
         }
         if (History.find({type: type}).fetch().length === 0) {

+ 1 - 1
app/templates/room.html

@@ -11,7 +11,7 @@
         <button type="button" id="search-song" class="button">Search</button>
         <div id="song-results"></div>
         <!--src="http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=1&controls=0&autohide=1">-->
-        
+
         <div width="960" height="540" id="player">
         </div>
         <ul class="bg-bubbles">