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

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

Issue 2305623003: Support to repeat one song in Audio Player. (Closed)
Patch Set: Support to repeat one song in Audio Player. Created 4 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
Index: ui/file_manager/audio_player/elements/audio_player.js
diff --git a/ui/file_manager/audio_player/elements/audio_player.js b/ui/file_manager/audio_player/elements/audio_player.js
index 879d85ef56b1255a5f1d80e409c123748e89549c..37fc307ce331276ce29e5ced81f8ddf99c649eec 100644
--- a/ui/file_manager/audio_player/elements/audio_player.js
+++ b/ui/file_manager/audio_player/elements/audio_player.js
@@ -41,10 +41,11 @@ Polymer({
},
/**
- * Whether the repeat button is ON.
+ * What mode the repeat button idicates.
+ * repeat-modes can be "repeat-none", "repeat-all", "repeat-one".
*/
- repeat: {
- type: Boolean,
+ repeatMode: {
+ type: String,
notify: true
},
@@ -223,7 +224,13 @@ Polymer({
*/
onAudioEnded: function() {
this.playcount++;
- this.advance_(true /* forward */, this.repeat);
+
+ if(this.repeatMode === "repeat-one") {
+ this.playing = true;
+ this.$.audio.currentTime = 0;
+ return;
+ }
+ this.advance_(true /* forward */, this.repeatMode === "repeat-all");
},
/**
@@ -231,7 +238,12 @@ Polymer({
* This handler is registered in this.ready().
*/
onAudioError: function() {
- this.scheduleAutoAdvance_(true /* forward */, this.repeat);
+ if(this.repeatMode === "repeat-one") {
+ this.playing = false;
+ return;
+ }
+ this.scheduleAutoAdvance_(
+ true /* forward */, this.repeatMode === "repeat-all");
},
/**
@@ -267,7 +279,8 @@ Polymer({
/**
* Goes to the previous or the next track.
* @param {boolean} forward True if next, false if previous.
- * @param {boolean} repeat True if repeat-mode is enabled. False otherwise.
+ * @param {boolean} repeat True if repeat-mode is "repeat-all". False
+ * "repeat-none".
* @private
*/
advance_: function(forward, repeat) {

Powered by Google App Engine
This is Rietveld 408576698