Pārlūkot izejas kodu

Added notification to tell user if the duration specified for a song is bigger than the duration of a video.

KrisVos130 9 gadi atpakaļ
vecāks
revīzija
1bfd7da46e
1 mainītis faili ar 24 papildinājumiem un 14 dzēšanām
  1. 24 14
      app/client/client.js

+ 24 - 14
app/client/client.js

@@ -959,26 +959,36 @@ Template.stations.events({
         }
     },
     "click #forward": function() {
+        console.log(yt_player);
+        console.log(Session.get("song"));
+        var error = false;
         if (yt_player !== undefined) {
-            yt_player.seekTo(Session.get("song").duration - 10);
+            if (yt_player.getDuration() < Session.get("song").duration) {
+                alert("The duration of the YouTube video is smaller than the duration.");
+                error = true;
+            } else {
+                yt_player.seekTo(Session.get("song").duration - 10);
+            }
         }
         if (_sound !== undefined) {
             _sound.seekTo((Session.get("song").duration - 10) * 1000);
         }
-        if (previewEndSongTimeout !== undefined) {
-            Meteor.clearTimeout(previewEndSongTimeout);
-        }
-        Meteor.setTimeout(function() {
-            if (yt_player !== undefined) {
-                yt_player.stopVideo();
-            }
-            if (_sound !== undefined) {
-                _sound.stop();
+        if (!error) {
+            if (previewEndSongTimeout !== undefined) {
+                Meteor.clearTimeout(previewEndSongTimeout);
             }
-            $("#play").attr("disabled", false);
-            $("#stop").attr("disabled", true);
-            $("#previewPlayer").hide();
-        }, 10000);
+            Meteor.setTimeout(function() {
+                if (yt_player !== undefined) {
+                    yt_player.stopVideo();
+                }
+                if (_sound !== undefined) {
+                    _sound.stop();
+                }
+                $("#play").attr("disabled", false);
+                $("#stop").attr("disabled", true);
+                $("#previewPlayer").hide();
+            }, 10000);
+        }
     },
     "click #croom_create": function() {
         Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), function (err, res) {