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 }; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 this.mediaElem_.volume = targetVolume; | 64 this.mediaElem_.volume = targetVolume; |
65 }; | 65 }; |
66 | 66 |
67 /** | 67 /** |
68 * Adds basic keyboard handlers to the media widget. | 68 * Adds basic keyboard handlers to the media widget. |
69 */ | 69 */ |
70 cvox.ChromeVoxHTMLMediaWidget.prototype.eventHandler_ = function(evt) { | 70 cvox.ChromeVoxHTMLMediaWidget.prototype.eventHandler_ = function(evt) { |
71 if (evt.type == 'keydown') { | 71 if (evt.type == 'keydown') { |
72 // Space/Enter for play/pause toggle. | 72 // Space/Enter for play/pause toggle. |
73 if ((evt.keyCode == 13) || (evt.keyCode == 32)) { | 73 if ((evt.keyCode == 13) || (evt.keyCode == 32)) { |
74 if (this.mediaElem_.paused){ | 74 if (this.mediaElem_.paused) { |
75 this.mediaElem_.play(); | 75 this.mediaElem_.play(); |
76 } else { | 76 } else { |
77 this.mediaElem_.pause(); | 77 this.mediaElem_.pause(); |
78 } | 78 } |
79 } else if (evt.keyCode == 39) { // Right - FF | 79 } else if (evt.keyCode == 39) { // Right - FF |
80 this.jumpToTime_( | 80 this.jumpToTime_( |
81 this.mediaElem_.currentTime + (this.mediaElem_.duration/10)); | 81 this.mediaElem_.currentTime + (this.mediaElem_.duration / 10)); |
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 |