Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: ui/file_manager/file_manager/audio_player/elements/audio_player.js

Issue 534493002: Audio Player: Cancel scheduled advance if the track has been changed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the comment Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/audio_player/elements/audio_player.js
diff --git a/ui/file_manager/file_manager/audio_player/elements/audio_player.js b/ui/file_manager/file_manager/audio_player/elements/audio_player.js
index 8b8e262e477e796ea61fa1df3336a0e0b1e0e2cc..ee71220c5904ca606aad4c5f7a35a19a01af967b 100644
--- a/ui/file_manager/file_manager/audio_player/elements/audio_player.js
+++ b/ui/file_manager/file_manager/audio_player/elements/audio_player.js
@@ -261,15 +261,29 @@ Polymer('audio-player', {
*/
scheduleAutoAdvance_: function(forward, repeat) {
this.cancelAutoAdvance_();
- this.autoAdvanceTimer_ = setTimeout(
+ var currentTrackIndex = this.currentTrackIndex;
+
+ var timerId = setTimeout(
function() {
+ // If the other timer is scheduled, do nothing.
+ if (this.autoAdvanceTimer_ !== timerId)
+ return;
+
this.autoAdvanceTimer_ = null;
+
+ // If the track has been changed since the advance was scheduled, do
+ // nothing.
+ if (this.currentTrackIndex !== currentTrackIndex)
+ return;
+
// We are advancing only if the next track is not known to be invalid.
// This prevents an endless auto-advancing in the case when all tracks
// are invalid (we will only visit each track once).
this.advance_(forward, repeat, true /* only if valid */);
}.bind(this),
3000);
+
+ this.autoAdvanceTimer_ = timerId;
},
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698