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 /** | 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), |
18 this.toggleFullScreen_.wrap(this), | 19 this.toggleFullScreen_.wrap(this), |
19 videoContainer); | 20 videoContainer); |
20 | 21 |
21 this.playerContainer_ = playerContainer; | 22 this.playerContainer_ = playerContainer; |
22 this.decodeErrorOccured = false; | 23 this.decodeErrorOccured = false; |
23 | 24 |
24 this.casting = false; | 25 this.casting = false; |
25 | 26 |
26 this.updateStyle(); | 27 this.updateStyle(); |
27 window.addEventListener('resize', this.updateStyle.wrap(this)); | 28 window.addEventListener('resize', this.updateStyle.wrap(this)); |
28 var currentWindow = chrome.app.window.current(); | 29 var currentWindow = chrome.app.window.current(); |
29 currentWindow.onFullscreened.addListener( | 30 currentWindow.onFullscreened.addListener( |
30 this.onFullScreenChanged.bind(this, true)); | 31 this.onFullScreenChanged_.bind(this, true)); |
31 currentWindow.onRestored.addListener( | 32 currentWindow.onRestored.addListener( |
32 this.onFullScreenChanged.bind(this, false)); | 33 this.onFullScreenChanged_.bind(this, false)); |
33 document.addEventListener('keydown', function(e) { | 34 document.addEventListener('keydown', function(e) { |
34 switch (util.getKeyModifiers(e) + e.keyIdentifier) { | 35 switch (util.getKeyModifiers(e) + e.keyIdentifier) { |
35 // Handle debug shortcut keys. | 36 // Handle debug shortcut keys. |
36 case 'Ctrl-Shift-U+0049': // Ctrl+Shift+I | 37 case 'Ctrl-Shift-U+0049': // Ctrl+Shift+I |
37 chrome.fileManagerPrivate.openInspector('normal'); | 38 chrome.fileManagerPrivate.openInspector('normal'); |
38 break; | 39 break; |
39 case 'Ctrl-Shift-U+004A': // Ctrl+Shift+J | 40 case 'Ctrl-Shift-U+004A': // Ctrl+Shift+J |
40 chrome.fileManagerPrivate.openInspector('console'); | 41 chrome.fileManagerPrivate.openInspector('console'); |
41 break; | 42 break; |
42 case 'Ctrl-Shift-U+0043': // Ctrl+Shift+C | 43 case 'Ctrl-Shift-U+0043': // Ctrl+Shift+C |
43 chrome.fileManagerPrivate.openInspector('element'); | 44 chrome.fileManagerPrivate.openInspector('element'); |
44 break; | 45 break; |
45 case 'Ctrl-Shift-U+0042': // Ctrl+Shift+B | 46 case 'Ctrl-Shift-U+0042': // Ctrl+Shift+B |
46 chrome.fileManagerPrivate.openInspector('background'); | 47 chrome.fileManagerPrivate.openInspector('background'); |
47 break; | 48 break; |
48 | 49 |
49 case 'U+0020': // Space | 50 case 'U+0020': // Space |
50 case 'MediaPlayPause': | 51 case 'MediaPlayPause': |
51 if (!e.target.classList.contains('menu-button')) | 52 this.togglePlayStateWithFeedback(); |
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 Loading... |
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 = str(message); | 123 errorBanner.textContent = loadTimeData.getString(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 Loading... |
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 /** |
171 * Media completion handler. | 184 * Media completion handler. |
172 */ | 185 */ |
173 FullWindowVideoControls.prototype.onMediaComplete = function() { | 186 FullWindowVideoControls.prototype.onMediaComplete = function() { |
174 VideoControls.prototype.onMediaComplete.apply(this, arguments); | 187 VideoControls.prototype.onMediaComplete.apply(this, arguments); |
175 if (!this.getMedia().loop) | 188 if (!this.getMedia().loop) |
176 player.advance_(1); | 189 player.advance_(1); |
177 }; | 190 }; |
178 | 191 |
179 /** | 192 /** |
180 * Video Player | 193 * Video Player |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 if (this.currentCast_) { | 574 if (this.currentCast_) { |
562 var currentCastAvailable = casts.some(function(cast) { | 575 var currentCastAvailable = casts.some(function(cast) { |
563 return this.currentCast_.label === cast.label; | 576 return this.currentCast_.label === cast.label; |
564 }.wrap(this)); | 577 }.wrap(this)); |
565 | 578 |
566 if (!currentCastAvailable) | 579 if (!currentCastAvailable) |
567 this.onCurrentCastDisappear_(); | 580 this.onCurrentCastDisappear_(); |
568 } | 581 } |
569 | 582 |
570 var item = new cr.ui.MenuItem(); | 583 var item = new cr.ui.MenuItem(); |
571 item.label = str('VIDEO_PLAYER_PLAY_THIS_COMPUTER'); | 584 item.label = loadTimeData.getString('VIDEO_PLAYER_PLAY_THIS_COMPUTER'); |
572 item.setAttribute('aria-label', item.label); | 585 item.setAttribute('aria-label', item.label); |
573 item.castLabel = ''; | 586 item.castLabel = ''; |
574 item.addEventListener('activate', this.onCastSelected_.wrap(this, null)); | 587 item.addEventListener('activate', this.onCastSelected_.wrap(this, null)); |
575 menu.appendChild(item); | 588 menu.appendChild(item); |
576 | 589 |
577 for (var i = 0; i < casts.length; i++) { | 590 for (var i = 0; i < casts.length; i++) { |
578 var item = new cr.ui.MenuItem(); | 591 var item = new cr.ui.MenuItem(); |
579 item.label = casts[i].friendlyName; | 592 item.label = casts[i].friendlyName; |
580 item.setAttribute('aria-label', item.label); | 593 item.setAttribute('aria-label', item.label); |
581 item.castLabel = casts[i].label; | 594 item.castLabel = casts[i].label; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 return new Promise(function(fulfill, reject) { | 677 return new Promise(function(fulfill, reject) { |
665 util.URLsToEntries(window.appState.items, function(entries) { | 678 util.URLsToEntries(window.appState.items, function(entries) { |
666 metrics.recordOpenVideoPlayerAction(); | 679 metrics.recordOpenVideoPlayerAction(); |
667 metrics.recordNumberOfOpenedFiles(entries.length); | 680 metrics.recordNumberOfOpenedFiles(entries.length); |
668 | 681 |
669 player.prepare(entries); | 682 player.prepare(entries); |
670 player.playFirstVideo(player, fulfill); | 683 player.playFirstVideo(player, fulfill); |
671 }.wrap()); | 684 }.wrap()); |
672 }.wrap()); | 685 }.wrap()); |
673 }.wrap()); | 686 }.wrap()); |
OLD | NEW |