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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 | 342 |
343 this.$.trackList.tracks = tracks; | 343 this.$.trackList.tracks = tracks; |
344 var currentTrack = this.$.trackList.getCurrentTrack(); | 344 var currentTrack = this.$.trackList.getCurrentTrack(); |
345 if (currentTrack && currentTrack.url != this.$.audio.src) { | 345 if (currentTrack && currentTrack.url != this.$.audio.src) { |
346 this.$.audio.src = currentTrack.url; | 346 this.$.audio.src = currentTrack.url; |
347 this.$.audio.play(); | 347 this.$.audio.play(); |
348 } | 348 } |
349 }, | 349 }, |
350 | 350 |
351 /** | 351 /** |
352 * Notifis the track-list element that the metadata for specified track is | |
353 * updated. | |
354 * @param {number} index The index of the track whose metadata is updated. | |
355 */ | |
356 notifyTrackMetadataUpdated: function(index) { | |
yoshiki
2016/01/14 11:10:27
nit: should we check if the argument is valid just
fukino
2016/01/14 11:32:35
Added a check for index range. Done.
| |
357 this.$.trackList.notifyPath('tracks.' + index + '.title', | |
358 this.tracks[index].title); | |
359 this.$.trackList.notifyPath('tracks.' + index + '.artist', | |
360 this.tracks[index].artist); | |
361 }, | |
362 | |
363 /** | |
352 * Invoked when the audio player is being unloaded. | 364 * Invoked when the audio player is being unloaded. |
353 */ | 365 */ |
354 onPageUnload: function() { | 366 onPageUnload: function() { |
355 this.$.audio.src = ''; // Hack to prevent crashing. | 367 this.$.audio.src = ''; // Hack to prevent crashing. |
356 }, | 368 }, |
357 | 369 |
358 /** | 370 /** |
359 * Invoked when dragging state of seek bar on control panel is changed. | 371 * Invoked when dragging state of seek bar on control panel is changed. |
360 * During the user is dragging it, audio playback is paused temporalily. | 372 * During the user is dragging it, audio playback is paused temporalily. |
361 */ | 373 */ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 | 408 |
397 /** | 409 /** |
398 * Computes volume value for audio element. (should be in [0.0, 1.0]) | 410 * Computes volume value for audio element. (should be in [0.0, 1.0]) |
399 * @param {number} volume Volume which is set in the UI. ([0, 100]) | 411 * @param {number} volume Volume which is set in the UI. ([0, 100]) |
400 * @return {number} | 412 * @return {number} |
401 */ | 413 */ |
402 computeAudioVolume_: function(volume) { | 414 computeAudioVolume_: function(volume) { |
403 return volume / 100; | 415 return volume / 100; |
404 } | 416 } |
405 }); | 417 }); |
OLD | NEW |