| 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 Polymer({ | 5 Polymer({ |
| 6 is: 'audio-player', | 6 is: 'audio-player', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 /** | 9 /** |
| 10 * Flag whether the audio is playing or paused. True if playing, or false | 10 * Flag whether the audio is playing or paused. True if playing, or false |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 */ | 264 */ |
| 265 advance_: function(forward, repeat) { | 265 advance_: function(forward, repeat) { |
| 266 this.cancelAutoAdvance_(); | 266 this.cancelAutoAdvance_(); |
| 267 | 267 |
| 268 var nextTrackIndex = this.$.trackList.getNextTrackIndex(forward, true); | 268 var nextTrackIndex = this.$.trackList.getNextTrackIndex(forward, true); |
| 269 var isNextTrackAvailable = | 269 var isNextTrackAvailable = |
| 270 (this.$.trackList.getNextTrackIndex(forward, repeat) !== -1); | 270 (this.$.trackList.getNextTrackIndex(forward, repeat) !== -1); |
| 271 | 271 |
| 272 this.playing = isNextTrackAvailable; | 272 this.playing = isNextTrackAvailable; |
| 273 | 273 |
| 274 // If there is only a single file in the list, 'currentTrackInde' is not | 274 var shouldFireEvent = this.$.trackList.currentTrackIndex === nextTrackIndex; |
| 275 // changed and the handler is not invoked. Instead, plays here. | 275 this.$.trackList.currentTrackIndex = nextTrackIndex; |
| 276 // TODO(yoshiki): clean up the code around here. | 276 this.$.audio.currentTime = 0; |
| 277 if (isNextTrackAvailable && | 277 // If the next track and current track is the same, |
| 278 this.$.trackList.currentTrackIndex == nextTrackIndex) { | 278 // the event will not be fired. |
| 279 this.$.audio.play(); | 279 // So we will fire the event here. |
| 280 // This happenes if there is only one song. |
| 281 if (shouldFireEvent) { |
| 282 this.$.trackList.fire('current-track-index-changed'); |
| 280 } | 283 } |
| 281 | |
| 282 this.$.trackList.currentTrackIndex = nextTrackIndex; | |
| 283 }, | 284 }, |
| 284 | 285 |
| 285 /** | 286 /** |
| 286 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and | 287 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and |
| 287 * cancelAutoAdvance_(). | 288 * cancelAutoAdvance_(). |
| 288 * @type {number?} | 289 * @type {number?} |
| 289 * @private | 290 * @private |
| 290 */ | 291 */ |
| 291 autoAdvanceTimer_: null, | 292 autoAdvanceTimer_: null, |
| 292 | 293 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 438 |
| 438 /** | 439 /** |
| 439 * Computes volume value for audio element. (should be in [0.0, 1.0]) | 440 * Computes volume value for audio element. (should be in [0.0, 1.0]) |
| 440 * @param {number} volume Volume which is set in the UI. ([0, 100]) | 441 * @param {number} volume Volume which is set in the UI. ([0, 100]) |
| 441 * @return {number} | 442 * @return {number} |
| 442 */ | 443 */ |
| 443 computeAudioVolume_: function(volume) { | 444 computeAudioVolume_: function(volume) { |
| 444 return volume / 100; | 445 return volume / 100; |
| 445 } | 446 } |
| 446 }); | 447 }); |
| OLD | NEW |