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

Side by Side Diff: chrome/browser/resources/file_manager/audio_player/elements/audio_player.js

Issue 144713008: [AudioPlayer] Implement shuffle mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/audio_player/elements/control_panel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 Polymer('audio-player', { 7 Polymer('audio-player', {
8 /** 8 /**
9 * Child Elements 9 * Child Elements
10 */ 10 */
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (this.audioElement.readyState !== 0) 123 if (this.audioElement.readyState !== 0)
124 this.audioElement.currentTime = this.audioController.time / 1000; 124 this.audioElement.currentTime = this.audioController.time / 1000;
125 }, 125 },
126 126
127 /** 127 /**
128 * Invoked when audioController.shuffle is changed. 128 * Invoked when audioController.shuffle is changed.
129 * @param {boolean} oldValue old value. 129 * @param {boolean} oldValue old value.
130 * @param {boolean} newValue new value. 130 * @param {boolean} newValue new value.
131 */ 131 */
132 onControllerShuffleChanged: function(oldValue, newValue) { 132 onControllerShuffleChanged: function(oldValue, newValue) {
133 // TODO(yoshiki): Implement shuffle mode. 133 this.trackList.shuffle = newValue;
134 }, 134 },
135 135
136 /** 136 /**
137 * Invoked when audioController.repeat is changed. 137 * Invoked when audioController.repeat is changed.
138 * @param {boolean} oldValue old value. 138 * @param {boolean} oldValue old value.
139 * @param {boolean} newValue new value. 139 * @param {boolean} newValue new value.
140 */ 140 */
141 onControllerRepeatChanged: function(oldValue, newValue) { 141 onControllerRepeatChanged: function(oldValue, newValue) {
142 this.trackList.repeat = newValue; 142 this.trackList.repeat = newValue;
143 }, 143 },
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 /** 188 /**
189 * Goes to the previous or the next track. 189 * Goes to the previous or the next track.
190 * @param {boolean} forward True if next, false if previous. 190 * @param {boolean} forward True if next, false if previous.
191 * @param {boolean} repeat True if repeat-mode is enabled. False otherwise. 191 * @param {boolean} repeat True if repeat-mode is enabled. False otherwise.
192 * @private 192 * @private
193 */ 193 */
194 advance_: function(forward, repeat) { 194 advance_: function(forward, repeat) {
195 this.cancelAutoAdvance_(); 195 this.cancelAutoAdvance_();
196 196
197 var nextTrackIndex = this.trackList.getNextTrackIndex(forward); 197 var nextTrackIndex = this.trackList.getNextTrackIndex(forward, true);
198 var nextTrack = this.trackList.tracks[nextTrackIndex]; 198 var isNextTrackAvailable =
199 var isNextTrackAvailable = this.trackList.isNextTrackAvailable(forward); 199 (this.trackList.getNextTrackIndex(forward, repeat) !== -1);
200 200
201 this.trackList.currentTrackIndex = nextTrackIndex; 201 this.trackList.currentTrackIndex = nextTrackIndex;
202 202
203 if (isNextTrackAvailable || repeat && nextTrack) { 203 if (isNextTrackAvailable) {
204 var nextTrack = this.trackList.tracks[nextTrackIndex];
204 this.audioElement.src = nextTrack.url; 205 this.audioElement.src = nextTrack.url;
205 this.audioElement.play(); 206 this.audioElement.play();
206 } else { 207 } else {
207 this.audioElement.pause(); 208 this.audioElement.pause();
208 } 209 }
209 }, 210 },
210 211
211 /** 212 /**
212 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and 213 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and
213 * cancelAutoAdvance_(). 214 * cancelAutoAdvance_().
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 this.audioController.playlistExpanded = !!expand; 301 this.audioController.playlistExpanded = !!expand;
301 }, 302 },
302 303
303 /** 304 /**
304 * Invoked when the audio player is being unloaded. 305 * Invoked when the audio player is being unloaded.
305 */ 306 */
306 onPageUnload: function() { 307 onPageUnload: function() {
307 this.audioElement.src = ''; // Hack to prevent crashing. 308 this.audioElement.src = ''; // Hack to prevent crashing.
308 }, 309 },
309 }); 310 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/audio_player/elements/control_panel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698