Chromium Code Reviews| 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..ee3c5c3b56378647bd21f64eab02e01bafa18df6 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, |
| + type: String, |
| notify: true |
| }, |
| @@ -206,7 +207,7 @@ Polymer({ |
| * This handler is registered in the 'on-click' attribute of the element. |
| */ |
| onControllerNextClicked: function() { |
| - this.advance_(true /* forward */, true /* repeat */); |
| + this.advance_(true /* forward */, "repeat-all"); |
| }, |
| /** |
| @@ -214,7 +215,7 @@ Polymer({ |
| * This handler is registered in the 'on-click' attribute of the element. |
| */ |
| onControllerPreviousClicked: function() { |
| - this.advance_(false /* forward */, true /* repeat */); |
| + this.advance_(false /* forward */, "repeat-all"); |
| }, |
| /** |
| @@ -267,12 +268,23 @@ 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 {string} repeatMode Repeat mode name. |
| * @private |
| */ |
| - advance_: function(forward, repeat) { |
| + advance_: function(forward, repeatMode) { |
|
fukino
2016/09/02 12:11:48
I think we don't need to change this advance_ func
harukam
2016/09/05 04:35:03
scheduleAutoAdvance_ is called only when error hap
fukino
2016/09/05 11:44:13
I think this should work:
1) On onAudioEnded, we r
harukam
2016/09/09 04:54:50
OK. Thanks.
|
| + console.assert(repeatMode == "repeat-none" || repeatMode === "repeat-all" || |
| + repeatMode == "repeat-one"); |
| + |
| this.cancelAutoAdvance_(); |
| + if(repeatMode === "repeat-one") { |
| + this.playing = true; |
| + this.$.audio.currentTime = 0; |
| + this.$.trackList.fire('current-track-index-changed'); |
|
harukam
2016/09/02 11:27:27
Question, do you think this line is necessary?
Acc
fukino
2016/09/02 12:11:48
According to https://codereview.chromium.org/16818
harukam
2016/09/05 04:35:03
Thanks for the link. It works without the event fi
fukino
2016/09/05 11:44:13
Maybe we can drop the current-track-index-changed
harukam
2016/09/09 04:54:50
Acknowledged.
|
| + return; |
| + } |
| + |
| + var repeat = repeatMode === "repeat-all"; |
| var nextTrackIndex = this.$.trackList.getNextTrackIndex(forward, true); |
| var isNextTrackAvailable = |
| (this.$.trackList.getNextTrackIndex(forward, repeat) !== -1); |
| @@ -302,10 +314,10 @@ Polymer({ |
| /** |
| * Schedules automatic advance to the next track after a timeout. |
| * @param {boolean} forward True if next, false if previous. |
| - * @param {boolean} repeat True if repeat-mode is enabled. False otherwise. |
| + * @param {string} repeatMode Repeat mode name. |
| * @private |
| */ |
| - scheduleAutoAdvance_: function(forward, repeat) { |
| + scheduleAutoAdvance_: function(forward, repeatMode) { |
| this.cancelAutoAdvance_(); |
| var currentTrackIndex = this.currentTrackIndex; |
| @@ -325,7 +337,7 @@ Polymer({ |
| // 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); |
| + this.advance_(forward, repeatMode); |
| }.bind(this), |
| 3000); |