| 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 goog.provide('cvox.ChromeVoxHTMLMediaWidget'); | 5 goog.provide('cvox.ChromeVoxHTMLMediaWidget'); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @fileoverview Gives the user spoken feedback as they interact with the HTML5 | 8 * @fileoverview Gives the user spoken feedback as they interact with the HTML5 |
| 9 * media widgets (<video> and <audio>) + makes the widget keyboard accessible. | 9 * media widgets (<video> and <audio>) + makes the widget keyboard accessible. |
| 10 * | 10 * |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * A class containing the information needed to speak | 14 * A class containing the information needed to speak |
| 15 * a media element to the user. | 15 * a media element to the user. |
| 16 * | 16 * |
| 17 * @constructor | 17 * @constructor |
| 18 * @param {Element} mediaElem The media widget element. | 18 * @param {Element} mediaElem The media widget element. |
| 19 * @param {cvox.TtsInterface} tts The TTS object from ChromeVox. | 19 * @param {cvox.TtsInterface} tts The TTS object from ChromeVox. |
| 20 */ | 20 */ |
| 21 cvox.ChromeVoxHTMLMediaWidget = function(mediaElem, tts){ | 21 cvox.ChromeVoxHTMLMediaWidget = function(mediaElem, tts){ |
| 22 var self = this; | 22 var self = this; |
| 23 this.mediaElem_ = mediaElem; | 23 this.mediaElem_ = mediaElem; |
| 24 this.mediaTts_ = tts; | 24 this.mediaTts_ = tts; |
| 25 | 25 |
| 26 this.keyListener_ = function(evt) { | 26 this.keyListener_ = function(evt) { |
| 27 self.eventHandler_(evt); | 27 self.eventHandler_(evt); |
| 28 } | 28 }; |
| 29 this.blurListener_ = function(evt) { | 29 this.blurListener_ = function(evt) { |
| 30 self.shutdown(); | 30 self.shutdown(); |
| 31 } | 31 }; |
| 32 | 32 |
| 33 this.mediaElem_.addEventListener('keydown', this.keyListener_, false); | 33 this.mediaElem_.addEventListener('keydown', this.keyListener_, false); |
| 34 this.mediaElem_.addEventListener('keyup', this.keyListener_, false); | 34 this.mediaElem_.addEventListener('keyup', this.keyListener_, false); |
| 35 this.mediaElem_.addEventListener('blur', this.blurListener_, false); | 35 this.mediaElem_.addEventListener('blur', this.blurListener_, false); |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * Removes the key listeners for the media widget. | 39 * Removes the key listeners for the media widget. |
| 40 */ | 40 */ |
| 41 cvox.ChromeVoxHTMLMediaWidget.prototype.shutdown = function() { | 41 cvox.ChromeVoxHTMLMediaWidget.prototype.shutdown = function() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } else if (evt.keyCode == 37) { // Left - REW | 82 } else if (evt.keyCode == 37) { // Left - REW |
| 83 this.jumpToTime_( | 83 this.jumpToTime_( |
| 84 this.mediaElem_.currentTime - (this.mediaElem_.duration/10)); | 84 this.mediaElem_.currentTime - (this.mediaElem_.duration/10)); |
| 85 } else if (evt.keyCode == 38) { // Up - Vol. Up | 85 } else if (evt.keyCode == 38) { // Up - Vol. Up |
| 86 this.setVolume_(this.mediaElem_.volume + .1); | 86 this.setVolume_(this.mediaElem_.volume + .1); |
| 87 } else if (evt.keyCode == 40) { // Down - Vol. Down | 87 } else if (evt.keyCode == 40) { // Down - Vol. Down |
| 88 this.setVolume_(this.mediaElem_.volume - .1); | 88 this.setVolume_(this.mediaElem_.volume - .1); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 }; | 91 }; |
| OLD | NEW |