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

Side by Side Diff: ui/file_manager/audio_player/elements/audio_player.js

Issue 2305623003: Support to repeat one song in Audio Player. (Closed)
Patch Set: Add a test for 3 repeat mode. 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 unified diff | Download patch
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 Polymer({ 5 Polymer({
6 is: 'audio-player', 6 is: 'audio-player',
7 7
8 listeners: { 8 listeners: {
9 'toggle-pause-event': 'onTogglePauseEvent_', 9 'toggle-pause-event': 'onTogglePauseEvent_',
10 'small-forward-skip-event': 'onSmallForwardSkipEvent_', 10 'small-forward-skip-event': 'onSmallForwardSkipEvent_',
(...skipping 23 matching lines...) Expand all
34 34
35 /** 35 /**
36 * Whether the shuffle button is ON. 36 * Whether the shuffle button is ON.
37 */ 37 */
38 shuffle: { 38 shuffle: {
39 type: Boolean, 39 type: Boolean,
40 notify: true 40 notify: true
41 }, 41 },
42 42
43 /** 43 /**
44 * Whether the repeat button is ON. 44 * What mode the repeat button idicates.
45 * repeat-modes can be "no-repeat", "repeat-all", "repeat-one".
45 */ 46 */
46 repeat: { 47 repeatMode: {
47 type: Boolean, 48 type: String,
48 notify: true 49 notify: true
49 }, 50 },
50 51
51 /** 52 /**
52 * The audio volume. 0 is silent, and 100 is maximum loud. 53 * The audio volume. 0 is silent, and 100 is maximum loud.
53 */ 54 */
54 volume: { 55 volume: {
55 type: Number, 56 type: Number,
56 notify: true 57 notify: true
57 }, 58 },
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 onControllerPreviousClicked: function() { 217 onControllerPreviousClicked: function() {
217 this.advance_(false /* forward */, true /* repeat */); 218 this.advance_(false /* forward */, true /* repeat */);
218 }, 219 },
219 220
220 /** 221 /**
221 * Invoked when the playback in the audio element is ended. 222 * Invoked when the playback in the audio element is ended.
222 * This handler is registered in this.ready(). 223 * This handler is registered in this.ready().
223 */ 224 */
224 onAudioEnded: function() { 225 onAudioEnded: function() {
225 this.playcount++; 226 this.playcount++;
226 this.advance_(true /* forward */, this.repeat); 227
228 if(this.repeatMode === "repeat-one") {
229 this.playing = true;
230 this.$.audio.currentTime = 0;
231 return;
232 }
233 this.advance_(true /* forward */, this.repeatMode === "repeat-all");
227 }, 234 },
228 235
229 /** 236 /**
230 * Invoked when the playback in the audio element gets error. 237 * Invoked when the playback in the audio element gets error.
231 * This handler is registered in this.ready(). 238 * This handler is registered in this.ready().
232 */ 239 */
233 onAudioError: function() { 240 onAudioError: function() {
234 this.scheduleAutoAdvance_(true /* forward */, this.repeat); 241 if(this.repeatMode === "repeat-one") {
242 this.playing = false;
243 return;
244 }
245 this.scheduleAutoAdvance_(
246 true /* forward */, this.repeatMode === "repeat-all");
235 }, 247 },
236 248
237 /** 249 /**
238 * Invoked when the time of playback in the audio element is updated. 250 * Invoked when the time of playback in the audio element is updated.
239 * This handler is registered in this.ready(). 251 * This handler is registered in this.ready().
240 * @private 252 * @private
241 */ 253 */
242 onAudioStatusUpdate_: function() { 254 onAudioStatusUpdate_: function() {
243 this.time = (this.lastAudioUpdateTime_ = this.$.audio.currentTime * 1000); 255 this.time = (this.lastAudioUpdateTime_ = this.$.audio.currentTime * 1000);
244 this.duration = this.$.audio.duration * 1000; 256 this.duration = this.$.audio.duration * 1000;
(...skipping 15 matching lines...) Expand all
260 // Changes the current time back to the beginning, regardless of the current 272 // Changes the current time back to the beginning, regardless of the current
261 // status (playing or paused). 273 // status (playing or paused).
262 this.$.audio.currentTime = 0; 274 this.$.audio.currentTime = 0;
263 this.time = 0; 275 this.time = 0;
264 this.$.audio.play(); 276 this.$.audio.play();
265 }, 277 },
266 278
267 /** 279 /**
268 * Goes to the previous or the next track. 280 * Goes to the previous or the next track.
269 * @param {boolean} forward True if next, false if previous. 281 * @param {boolean} forward True if next, false if previous.
270 * @param {boolean} repeat True if repeat-mode is enabled. False otherwise. 282 * @param {boolean} repeat True if repeat-mode is "repeat-all". False
283 * "no-repeat".
271 * @private 284 * @private
272 */ 285 */
273 advance_: function(forward, repeat) { 286 advance_: function(forward, repeat) {
274 this.cancelAutoAdvance_(); 287 this.cancelAutoAdvance_();
275 288
276 var nextTrackIndex = this.$.trackList.getNextTrackIndex(forward, true); 289 var nextTrackIndex = this.$.trackList.getNextTrackIndex(forward, true);
277 var isNextTrackAvailable = 290 var isNextTrackAvailable =
278 (this.$.trackList.getNextTrackIndex(forward, repeat) !== -1); 291 (this.$.trackList.getNextTrackIndex(forward, repeat) !== -1);
279 292
280 this.playing = isNextTrackAvailable; 293 this.playing = isNextTrackAvailable;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 }, 499 },
487 500
488 /** 501 /**
489 * Big skip backword. 502 * Big skip backword.
490 * @private 503 * @private
491 */ 504 */
492 onBigBackwordSkipEvent_: function(event) { 505 onBigBackwordSkipEvent_: function(event) {
493 this.$.audioController.bigSkip(false); 506 this.$.audioController.bigSkip(false);
494 }, 507 },
495 }); 508 });
OLDNEW
« no previous file with comments | « ui/file_manager/audio_player/elements/audio_player.html ('k') | ui/file_manager/audio_player/elements/compiled_resources2.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698