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 loadTimeData.getString.wrap(loadTimeData), |
19 this.toggleFullScreen_.wrap(this), | 19 this.toggleFullScreen_.wrap(this), |
20 videoContainer); | 20 videoContainer); |
21 | 21 |
22 this.playerContainer_ = playerContainer; | 22 this.playerContainer_ = playerContainer; |
23 this.decodeErrorOccured = false; | 23 this.decodeErrorOccured = false; |
24 | 24 |
25 this.casting = false; | 25 this.casting = false; |
26 | 26 |
27 this.updateStyle(); | 27 this.updateStyle(); |
28 window.addEventListener('resize', this.updateStyle.wrap(this)); | 28 window.addEventListener('resize', this.updateStyle.wrap(this)); |
| 29 var currentWindow = chrome.app.window.current(); |
| 30 currentWindow.onFullscreened.addListener( |
| 31 this.onFullScreenChanged_.bind(this, true)); |
| 32 currentWindow.onRestored.addListener( |
| 33 this.onFullScreenChanged_.bind(this, false)); |
29 document.addEventListener('keydown', function(e) { | 34 document.addEventListener('keydown', function(e) { |
30 switch (util.getKeyModifiers(e) + e.keyIdentifier) { | 35 switch (util.getKeyModifiers(e) + e.keyIdentifier) { |
31 // Handle debug shortcut keys. | 36 // Handle debug shortcut keys. |
32 case 'Ctrl-Shift-U+0049': // Ctrl+Shift+I | 37 case 'Ctrl-Shift-U+0049': // Ctrl+Shift+I |
33 chrome.fileManagerPrivate.openInspector('normal'); | 38 chrome.fileManagerPrivate.openInspector('normal'); |
34 break; | 39 break; |
35 case 'Ctrl-Shift-U+004A': // Ctrl+Shift+J | 40 case 'Ctrl-Shift-U+004A': // Ctrl+Shift+J |
36 chrome.fileManagerPrivate.openInspector('console'); | 41 chrome.fileManagerPrivate.openInspector('console'); |
37 break; | 42 break; |
38 case 'Ctrl-Shift-U+0043': // Ctrl+Shift+C | 43 case 'Ctrl-Shift-U+0043': // Ctrl+Shift+C |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 /** | 161 /** |
157 * Toggles the full screen mode. | 162 * Toggles the full screen mode. |
158 * @private | 163 * @private |
159 */ | 164 */ |
160 FullWindowVideoControls.prototype.toggleFullScreen_ = function() { | 165 FullWindowVideoControls.prototype.toggleFullScreen_ = function() { |
161 var appWindow = chrome.app.window.current(); | 166 var appWindow = chrome.app.window.current(); |
162 util.toggleFullScreen(appWindow, !util.isFullScreen(appWindow)); | 167 util.toggleFullScreen(appWindow, !util.isFullScreen(appWindow)); |
163 }; | 168 }; |
164 | 169 |
165 /** | 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 /** |
166 * Media completion handler. | 184 * Media completion handler. |
167 */ | 185 */ |
168 FullWindowVideoControls.prototype.onMediaComplete = function() { | 186 FullWindowVideoControls.prototype.onMediaComplete = function() { |
169 VideoControls.prototype.onMediaComplete.apply(this, arguments); | 187 VideoControls.prototype.onMediaComplete.apply(this, arguments); |
170 if (!this.getMedia().loop) | 188 if (!this.getMedia().loop) |
171 player.advance_(1); | 189 player.advance_(1); |
172 }; | 190 }; |
173 | 191 |
174 /** | 192 /** |
175 * Video Player | 193 * Video Player |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 return new Promise(function(fulfill, reject) { | 677 return new Promise(function(fulfill, reject) { |
660 util.URLsToEntries(window.appState.items, function(entries) { | 678 util.URLsToEntries(window.appState.items, function(entries) { |
661 metrics.recordOpenVideoPlayerAction(); | 679 metrics.recordOpenVideoPlayerAction(); |
662 metrics.recordNumberOfOpenedFiles(entries.length); | 680 metrics.recordNumberOfOpenedFiles(entries.length); |
663 | 681 |
664 player.prepare(entries); | 682 player.prepare(entries); |
665 player.playFirstVideo(player, fulfill); | 683 player.playFirstVideo(player, fulfill); |
666 }.wrap()); | 684 }.wrap()); |
667 }.wrap()); | 685 }.wrap()); |
668 }.wrap()); | 686 }.wrap()); |
OLD | NEW |