unknown 9 年 前
コミット
f957b66d8a
3 ファイル変更33 行追加46 行削除
  1. 8 9
      app/app.css
  2. 24 35
      app/app.js
  3. 1 2
      app/head.html

+ 8 - 9
app/app.css

@@ -439,19 +439,18 @@ footer a:hover{
         background-color: red;
     }
 }
-
 #player {
     visibility: hidden;
 }
 .footerButtons {
-background:none!important;
-     border:none; 
-     padding:0!important;
-     font: inherit;
-     /*border is optional*/
-     border-bottom:1px solid #444; 
-     cursor: pointer;
+  background:none!important;
+  border:none;
+  padding:0!important;
+  font: inherit;
+  /*border is optional*/
+  border-bottom:1px solid #444;
+  cursor: pointer;
 }
 .footerButtons:hover {
   background-color: #f5f7f9;
-}
+}

+ 24 - 35
app/app.js

@@ -124,20 +124,21 @@ if (Meteor.isClient) {
                 var songObj = {
                   title: songsArr[i].title,
                   id: id,
-                  duration: duration
+                  duration: duration,
+                  type: "soundcloud"
                 }
               }
             }
             console.log(id);
-            Meteor.call("addToPlaylist", function(err,res){
+            Meteor.call("addToPlaylist", songObj, function(err,res){
               console.log(res);
-            })
-            if (_sound !== undefined)_sound.stop();
-            SC.stream("/tracks/" + id, function(sound){
-              _sound = sound;
-              sound._player._volume = 0.3;
-              sound.play()
             });
+            // if (_sound !== undefined)_sound.stop();
+            // SC.stream("/tracks/" + id, function(sound){
+            //   _sound = sound;
+            //   sound._player._volume = 0.3;
+            //   sound.play()
+            // });
           })
         });
       }
@@ -179,42 +180,30 @@ if (Meteor.isClient) {
         function startSong() {
             if (currentSong !== undefined) {
                 if (_sound !== undefined)_sound.stop();
-                SC.stream("/tracks/" + currentSong.song.id + "/", function(sound){
+                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();
+                    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").width(0);
+                    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");
+                    Session.set("title", currentSong.song.title || "Title");
+                    Session.set("artist", currentSong.song.artist || "Artist");
+                    Session.set("duration", currentSong.song.duration);
+                    $("#seeker-bar").css("transition", Session.get("duration") + "s");
+                    $("#seeker-bar").width(1400);
                 }
             }
         }
@@ -250,10 +239,9 @@ if (Meteor.isServer) {
 
     var startedAt = Date.now();
     var songs = [
-      {id: 216112412, title: "How Deep Is Your Love", artist: "Calvin Harris", duration: 193},
-      {id: 7971238, title: "The Time (Dirty Bit)", artist: "Black Eyed Pea", duration: 308}
+      {id: "eMrh3wYb1mM", title: "Where Are U Now", artist: "Pentatonix", duration: 244, type: "youtube"},
+      {id: 170202151, title: "Runnaway (U & I)", artist: "Galantis", duration: 193, type: "soundcloud"}
     ];
-    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);
 
@@ -318,7 +306,8 @@ if (Meteor.isServer) {
             }
             return true;
         },
-        addToPlaylist: function(){
+        addToPlaylist: function(songObj){
+          songs.push(songObj);
           return songs;
         }
     });

+ 1 - 2
app/head.html

@@ -2,7 +2,7 @@
     <title>Music App</title>
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="description" content="Welcome to the new modern, clean and awesome music app for the urban culture!">
+    <meta name="description" content="Welcome to the next gen, collaborative, modern music app for the web!">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
     <link href='http://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
@@ -25,4 +25,3 @@
         init();
     </script>
 </head>
-