| OLD | NEW |
| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 * @private | 198 * @private |
| 199 */ | 199 */ |
| 200 advance_: function(forward, repeat) { | 200 advance_: function(forward, repeat) { |
| 201 this.cancelAutoAdvance_(); | 201 this.cancelAutoAdvance_(); |
| 202 | 202 |
| 203 var nextTrackIndex = this.trackList.getNextTrackIndex(forward, true); | 203 var nextTrackIndex = this.trackList.getNextTrackIndex(forward, true); |
| 204 var isNextTrackAvailable = | 204 var isNextTrackAvailable = |
| 205 (this.trackList.getNextTrackIndex(forward, repeat) !== -1); | 205 (this.trackList.getNextTrackIndex(forward, repeat) !== -1); |
| 206 | 206 |
| 207 this.audioController.playing = isNextTrackAvailable; | 207 this.audioController.playing = isNextTrackAvailable; |
| 208 |
| 209 // If there is only a single file in the list, 'currentTrackInde' is not |
| 210 // changed and the handler is not invoked. Instead, plays here. |
| 211 // TODO(yoshiki): clean up the code around here. |
| 212 if (isNextTrackAvailable && |
| 213 this.trackList.currentTrackIndex == nextTrackIndex) { |
| 214 this.audioElement.play(); |
| 215 } |
| 216 |
| 208 this.trackList.currentTrackIndex = nextTrackIndex; | 217 this.trackList.currentTrackIndex = nextTrackIndex; |
| 209 | 218 |
| 210 Platform.performMicrotaskCheckpoint(); | 219 Platform.performMicrotaskCheckpoint(); |
| 211 }, | 220 }, |
| 212 | 221 |
| 213 /** | 222 /** |
| 214 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and | 223 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and |
| 215 * cancelAutoAdvance_(). | 224 * cancelAutoAdvance_(). |
| 216 * @type {number} | 225 * @type {number} |
| 217 * @private | 226 * @private |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 295 } |
| 287 }, | 296 }, |
| 288 | 297 |
| 289 /** | 298 /** |
| 290 * Invoked when the audio player is being unloaded. | 299 * Invoked when the audio player is being unloaded. |
| 291 */ | 300 */ |
| 292 onPageUnload: function() { | 301 onPageUnload: function() { |
| 293 this.audioElement.src = ''; // Hack to prevent crashing. | 302 this.audioElement.src = ''; // Hack to prevent crashing. |
| 294 }, | 303 }, |
| 295 }); | 304 }); |
| OLD | NEW |