Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed problems with server.js + cleaned up

  • Loading branch information...
commit 7401f35e4ad430ebd968e68c0fd313d3417f2d87 1 parent 2664c5b
@mpj authored
Showing with 18 additions and 13 deletions.
  1. +18 −13 server/server.js
View
31 server/server.js
@@ -53,20 +53,25 @@ var handle = query.observe({
*/
function checkForSkipping(playlistItemId) {
var pli = PlaylistItems.findOne(playlistItemId),
- isStillPlaying = !!pli.playing_since,
- isPastEnd = ((Number(new Date()) - pli.playing_since + pli.position)) > pli.duration;
-
- if (!isStillPlaying) {
- // Not playing anymore (somebody probably changed tracks, or scrubbed)
- return;
- }
-
- if(isPastEnd) {
- // Is playing, and has went past the end of the track.
- // This means that we should skip to the next track.
- var nextSibling = findNextSibling(pli);
- if (nextSibling) player.play(nextSibling);
+ now = Number(new Date()),
+ hasPlayedPastEnd = !!pli.playing_since &&
+ now - pli.playing_since + pli.position > pli.duration;
+
+ if (hasPlayedPastEnd) {
+
+ // Is playing, and has went past the end of the track.
+ // This means that we should skip to the next track.
+ var nextSibling = findNextSibling(pli);
+ if (nextSibling) player.play(nextSibling);
+
+ } else {
+
+ // Do nothing - this playlistItem did not play past
+ // end when we expected it to - somebody probably
+ // changed tracks, or scrubbed.
+
}
+
}
/*
Please sign in to comment.
Something went wrong with that request. Please try again.