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