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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 * This handler is registered in this.ready(). | 277 * This handler is registered in this.ready(). |
278 * @private | 278 * @private |
279 */ | 279 */ |
280 onAudioStatusUpdate_: function() { | 280 onAudioStatusUpdate_: function() { |
281 this.time = (this.lastAudioUpdateTime_ = this.$.audio.currentTime * 1000); | 281 this.time = (this.lastAudioUpdateTime_ = this.$.audio.currentTime * 1000); |
282 this.duration = this.$.audio.duration * 1000; | 282 this.duration = this.$.audio.duration * 1000; |
283 this.playing = !this.$.audio.paused; | 283 this.playing = !this.$.audio.paused; |
284 }, | 284 }, |
285 | 285 |
286 /** | 286 /** |
| 287 * Invoked when receivig a request to start playing the current music. |
| 288 */ |
| 289 onPlayCurrentTrack: function() { |
| 290 this.$.audio.play(); |
| 291 }, |
| 292 |
| 293 /** |
287 * Invoked when receiving a request to replay the current music from the track | 294 * Invoked when receiving a request to replay the current music from the track |
288 * list element. | 295 * list element. |
289 */ | 296 */ |
290 onReplayCurrentTrack: function() { | 297 onReplayCurrentTrack: function() { |
291 // Changes the current time back to the beginning, regardless of the current | 298 // Changes the current time back to the beginning, regardless of the current |
292 // status (playing or paused). | 299 // status (playing or paused). |
293 this.$.audio.currentTime = 0; | 300 this.$.audio.currentTime = 0; |
294 this.time = 0; | 301 this.time = 0; |
295 }, | 302 }, |
296 | 303 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 468 |
462 /** | 469 /** |
463 * Computes volume value for audio element. (should be in [0.0, 1.0]) | 470 * Computes volume value for audio element. (should be in [0.0, 1.0]) |
464 * @param {number} volume Volume which is set in the UI. ([0, 100]) | 471 * @param {number} volume Volume which is set in the UI. ([0, 100]) |
465 * @return {number} | 472 * @return {number} |
466 */ | 473 */ |
467 computeAudioVolume_: function(volume) { | 474 computeAudioVolume_: function(volume) { |
468 return volume / 100; | 475 return volume / 100; |
469 } | 476 } |
470 }); | 477 }); |
OLD | NEW |