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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 } | 432 } |
433 } | 433 } |
434 }, | 434 }, |
435 | 435 |
436 /** | 436 /** |
437 * Invoked when the 'keydown' event is fired. | 437 * Invoked when the 'keydown' event is fired. |
438 * @param {Event} event The event object. | 438 * @param {Event} event The event object. |
439 */ | 439 */ |
440 onKeyDown_: function(event) { | 440 onKeyDown_: function(event) { |
441 switch (event.keyIdentifier) { | 441 switch (event.keyIdentifier) { |
442 case 'Up': | |
443 if (this.$.audioController.volumeSliderShown && this.model.volume < 100) | |
444 this.model.volume += 1; | |
445 break; | |
446 case 'Down': | |
447 if (this.$.audioController.volumeSliderShown && this.model.volume > 0) | |
448 this.model.volume -= 1; | |
449 break; | |
450 case 'PageUp': | |
451 if (this.$.audioController.volumeSliderShown && this.model.volume < 91) | |
452 this.model.volume += 10; | |
453 break; | |
454 case 'PageDown': | |
455 if (this.$.audioController.volumeSliderShown && this.model.volume > 9) | |
456 this.model.volume -= 10; | |
457 break; | |
458 case 'MediaNextTrack': | 442 case 'MediaNextTrack': |
459 this.onControllerNextClicked(); | 443 this.onControllerNextClicked(); |
460 break; | 444 break; |
461 case 'MediaPlayPause': | 445 case 'MediaPlayPause': |
462 this.playing = !this.playing; | 446 this.playing = !this.playing; |
463 break; | 447 break; |
464 case 'MediaPreviousTrack': | 448 case 'MediaPreviousTrack': |
465 this.onControllerPreviousClicked(); | 449 this.onControllerPreviousClicked(); |
466 break; | 450 break; |
467 case 'MediaStop': | 451 case 'MediaStop': |
468 // TODO: Define "Stop" behavior. | 452 // TODO: Define "Stop" behavior. |
469 break; | 453 break; |
470 } | 454 } |
471 }, | 455 }, |
472 | 456 |
473 /** | 457 /** |
474 * Computes volume value for audio element. (should be in [0.0, 1.0]) | 458 * Computes volume value for audio element. (should be in [0.0, 1.0]) |
475 * @param {number} volume Volume which is set in the UI. ([0, 100]) | 459 * @param {number} volume Volume which is set in the UI. ([0, 100]) |
476 * @return {number} | 460 * @return {number} |
477 */ | 461 */ |
478 computeAudioVolume_: function(volume) { | 462 computeAudioVolume_: function(volume) { |
479 return volume / 100; | 463 return volume / 100; |
480 } | 464 } |
481 }); | 465 }); |
OLD | NEW |