Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: ui/file_manager/video_player/js/video_player.js

Issue 1435253002: VideoPlayer: Fix accessibility issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /** 5 /**
6 * @param {!HTMLElement} playerContainer Main container. 6 * @param {!HTMLElement} playerContainer Main container.
7 * @param {!HTMLElement} videoContainer Container for the video element. 7 * @param {!HTMLElement} videoContainer Container for the video element.
8 * @param {!HTMLElement} controlsContainer Container for video controls. 8 * @param {!HTMLElement} controlsContainer Container for video controls.
9 * @constructor 9 * @constructor
10 * @struct 10 * @struct
11 * @extends {VideoControls} 11 * @extends {VideoControls}
12 */ 12 */
13 function FullWindowVideoControls( 13 function FullWindowVideoControls(
14 playerContainer, videoContainer, controlsContainer) { 14 playerContainer, videoContainer, controlsContainer) {
15 VideoControls.call(this, 15 VideoControls.call(this,
16 controlsContainer, 16 controlsContainer,
17 this.onPlaybackError_.wrap(this), 17 this.onPlaybackError_.wrap(this),
18 loadTimeData.getString.wrap(loadTimeData),
19 this.toggleFullScreen_.wrap(this), 18 this.toggleFullScreen_.wrap(this),
20 videoContainer); 19 videoContainer);
21 20
22 this.playerContainer_ = playerContainer; 21 this.playerContainer_ = playerContainer;
23 this.decodeErrorOccured = false; 22 this.decodeErrorOccured = false;
24 23
25 this.casting = false; 24 this.casting = false;
26 25
27 this.updateStyle(); 26 this.updateStyle();
28 window.addEventListener('resize', this.updateStyle.wrap(this)); 27 window.addEventListener('resize', this.updateStyle.wrap(this));
29 var currentWindow = chrome.app.window.current(); 28 var currentWindow = chrome.app.window.current();
30 currentWindow.onFullscreened.addListener( 29 currentWindow.onFullscreened.addListener(
31 this.onFullScreenChanged_.bind(this, true)); 30 this.onFullScreenChanged.bind(this, true));
32 currentWindow.onRestored.addListener( 31 currentWindow.onRestored.addListener(
33 this.onFullScreenChanged_.bind(this, false)); 32 this.onFullScreenChanged.bind(this, false));
34 document.addEventListener('keydown', function(e) { 33 document.addEventListener('keydown', function(e) {
35 switch (util.getKeyModifiers(e) + e.keyIdentifier) { 34 switch (util.getKeyModifiers(e) + e.keyIdentifier) {
36 // Handle debug shortcut keys. 35 // Handle debug shortcut keys.
37 case 'Ctrl-Shift-U+0049': // Ctrl+Shift+I 36 case 'Ctrl-Shift-U+0049': // Ctrl+Shift+I
38 chrome.fileManagerPrivate.openInspector('normal'); 37 chrome.fileManagerPrivate.openInspector('normal');
39 break; 38 break;
40 case 'Ctrl-Shift-U+004A': // Ctrl+Shift+J 39 case 'Ctrl-Shift-U+004A': // Ctrl+Shift+J
41 chrome.fileManagerPrivate.openInspector('console'); 40 chrome.fileManagerPrivate.openInspector('console');
42 break; 41 break;
43 case 'Ctrl-Shift-U+0043': // Ctrl+Shift+C 42 case 'Ctrl-Shift-U+0043': // Ctrl+Shift+C
44 chrome.fileManagerPrivate.openInspector('element'); 43 chrome.fileManagerPrivate.openInspector('element');
45 break; 44 break;
46 case 'Ctrl-Shift-U+0042': // Ctrl+Shift+B 45 case 'Ctrl-Shift-U+0042': // Ctrl+Shift+B
47 chrome.fileManagerPrivate.openInspector('background'); 46 chrome.fileManagerPrivate.openInspector('background');
48 break; 47 break;
49 48
50 case 'U+0020': // Space 49 case 'U+0020': // Space
51 case 'MediaPlayPause': 50 case 'MediaPlayPause':
52 this.togglePlayStateWithFeedback(); 51 if (!e.target.classList.contains('menu-button'))
52 this.togglePlayStateWithFeedback();
53 break; 53 break;
54 case 'U+001B': // Escape 54 case 'U+001B': // Escape
55 util.toggleFullScreen( 55 util.toggleFullScreen(
56 chrome.app.window.current(), 56 chrome.app.window.current(),
57 false); // Leave the full screen mode. 57 false); // Leave the full screen mode.
58 break; 58 break;
59 case 'Right': 59 case 'Right':
60 case 'MediaNextTrack': 60 case 'MediaNextTrack':
61 player.advance_(1); 61 player.advance_(1);
62 break; 62 break;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return this.inactivityWatcher_; 113 return this.inactivityWatcher_;
114 }; 114 };
115 115
116 /** 116 /**
117 * Displays error message. 117 * Displays error message.
118 * 118 *
119 * @param {string} message Message id. 119 * @param {string} message Message id.
120 */ 120 */
121 FullWindowVideoControls.prototype.showErrorMessage = function(message) { 121 FullWindowVideoControls.prototype.showErrorMessage = function(message) {
122 var errorBanner = getRequiredElement('error'); 122 var errorBanner = getRequiredElement('error');
123 errorBanner.textContent = loadTimeData.getString(message); 123 errorBanner.textContent = str(message);
124 errorBanner.setAttribute('visible', 'true'); 124 errorBanner.setAttribute('visible', 'true');
125 125
126 // The window is hidden if the video has not loaded yet. 126 // The window is hidden if the video has not loaded yet.
127 chrome.app.window.current().show(); 127 chrome.app.window.current().show();
128 }; 128 };
129 129
130 /** 130 /**
131 * Handles playback (decoder) errors. 131 * Handles playback (decoder) errors.
132 * @param {MediaError} error Error object. 132 * @param {MediaError} error Error object.
133 * @private 133 * @private
(...skipping 27 matching lines...) Expand all
161 /** 161 /**
162 * Toggles the full screen mode. 162 * Toggles the full screen mode.
163 * @private 163 * @private
164 */ 164 */
165 FullWindowVideoControls.prototype.toggleFullScreen_ = function() { 165 FullWindowVideoControls.prototype.toggleFullScreen_ = function() {
166 var appWindow = chrome.app.window.current(); 166 var appWindow = chrome.app.window.current();
167 util.toggleFullScreen(appWindow, !util.isFullScreen(appWindow)); 167 util.toggleFullScreen(appWindow, !util.isFullScreen(appWindow));
168 }; 168 };
169 169
170 /** 170 /**
171 * Updates video control when the window is fullscreened or restored.
172 * @param {boolean} fullscreen True if the window gets fullscreened.
173 * @private
174 */
175 FullWindowVideoControls.prototype.onFullScreenChanged_ = function(fullscreen) {
176 if (fullscreen) {
177 this.playerContainer_.setAttribute('fullscreen', '');
178 } else {
179 this.playerContainer_.removeAttribute('fullscreen');
180 }
181 };
182
183 /**
184 * Media completion handler. 171 * Media completion handler.
185 */ 172 */
186 FullWindowVideoControls.prototype.onMediaComplete = function() { 173 FullWindowVideoControls.prototype.onMediaComplete = function() {
187 VideoControls.prototype.onMediaComplete.apply(this, arguments); 174 VideoControls.prototype.onMediaComplete.apply(this, arguments);
188 if (!this.getMedia().loop) 175 if (!this.getMedia().loop)
189 player.advance_(1); 176 player.advance_(1);
190 }; 177 };
191 178
192 /** 179 /**
193 * Video Player 180 * Video Player
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 if (this.currentCast_) { 561 if (this.currentCast_) {
575 var currentCastAvailable = casts.some(function(cast) { 562 var currentCastAvailable = casts.some(function(cast) {
576 return this.currentCast_.label === cast.label; 563 return this.currentCast_.label === cast.label;
577 }.wrap(this)); 564 }.wrap(this));
578 565
579 if (!currentCastAvailable) 566 if (!currentCastAvailable)
580 this.onCurrentCastDisappear_(); 567 this.onCurrentCastDisappear_();
581 } 568 }
582 569
583 var item = new cr.ui.MenuItem(); 570 var item = new cr.ui.MenuItem();
584 item.label = loadTimeData.getString('VIDEO_PLAYER_PLAY_THIS_COMPUTER'); 571 item.label = str('VIDEO_PLAYER_PLAY_THIS_COMPUTER');
585 item.setAttribute('aria-label', item.label); 572 item.setAttribute('aria-label', item.label);
586 item.castLabel = ''; 573 item.castLabel = '';
587 item.addEventListener('activate', this.onCastSelected_.wrap(this, null)); 574 item.addEventListener('activate', this.onCastSelected_.wrap(this, null));
588 menu.appendChild(item); 575 menu.appendChild(item);
589 576
590 for (var i = 0; i < casts.length; i++) { 577 for (var i = 0; i < casts.length; i++) {
591 var item = new cr.ui.MenuItem(); 578 var item = new cr.ui.MenuItem();
592 item.label = casts[i].friendlyName; 579 item.label = casts[i].friendlyName;
593 item.setAttribute('aria-label', item.label); 580 item.setAttribute('aria-label', item.label);
594 item.castLabel = casts[i].label; 581 item.castLabel = casts[i].label;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 return new Promise(function(fulfill, reject) { 664 return new Promise(function(fulfill, reject) {
678 util.URLsToEntries(window.appState.items, function(entries) { 665 util.URLsToEntries(window.appState.items, function(entries) {
679 metrics.recordOpenVideoPlayerAction(); 666 metrics.recordOpenVideoPlayerAction();
680 metrics.recordNumberOfOpenedFiles(entries.length); 667 metrics.recordNumberOfOpenedFiles(entries.length);
681 668
682 player.prepare(entries); 669 player.prepare(entries);
683 player.playFirstVideo(player, fulfill); 670 player.playFirstVideo(player, fulfill);
684 }.wrap()); 671 }.wrap());
685 }.wrap()); 672 }.wrap());
686 }.wrap()); 673 }.wrap());
OLDNEW
« no previous file with comments | « ui/file_manager/video_player/js/media_controls.js ('k') | ui/file_manager/video_player/video_player.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698