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 this.$.trackList.currentTrackIndex = nextTrackIndex; |
275 // changed and the handler is not invoked. Instead, plays here. | 275 this.$.audio.currentTime = 0; |
276 // TODO(yoshiki): clean up the code around here. | 276 // If the next track and current track is the same, |
277 if (isNextTrackAvailable && | 277 // the event will not be fired. |
278 this.$.trackList.currentTrackIndex == nextTrackIndex) { | 278 // So we will fire the event here. |
279 this.$.audio.play(); | 279 // This happenes if there is only one song. |
280 if (this.$.trackList.currentTrackIndex == nextTrackIndex) { | |
fukino
2016/02/09 05:13:17
This condition is always true. (by assignment at #
ryoh
2016/02/09 05:44:19
Done.
| |
281 this.$.trackList.fire('current-track-index-changed'); | |
280 } | 282 } |
281 | |
282 this.$.trackList.currentTrackIndex = nextTrackIndex; | |
283 }, | 283 }, |
284 | 284 |
285 /** | 285 /** |
286 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and | 286 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and |
287 * cancelAutoAdvance_(). | 287 * cancelAutoAdvance_(). |
288 * @type {number?} | 288 * @type {number?} |
289 * @private | 289 * @private |
290 */ | 290 */ |
291 autoAdvanceTimer_: null, | 291 autoAdvanceTimer_: null, |
292 | 292 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 | 437 |
438 /** | 438 /** |
439 * Computes volume value for audio element. (should be in [0.0, 1.0]) | 439 * 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]) | 440 * @param {number} volume Volume which is set in the UI. ([0, 100]) |
441 * @return {number} | 441 * @return {number} |
442 */ | 442 */ |
443 computeAudioVolume_: function(volume) { | 443 computeAudioVolume_: function(volume) { |
444 return volume / 100; | 444 return volume / 100; |
445 } | 445 } |
446 }); | 446 }); |
OLD | NEW |