| 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 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 * initialization. | 211 * initialization. |
| 212 * @param {!Array<!FileEntry>} videos List of videos. | 212 * @param {!Array<!FileEntry>} videos List of videos. |
| 213 */ | 213 */ |
| 214 VideoPlayer.prototype.prepare = function(videos) { | 214 VideoPlayer.prototype.prepare = function(videos) { |
| 215 this.videos_ = videos; | 215 this.videos_ = videos; |
| 216 | 216 |
| 217 var preventDefault = function(event) { event.preventDefault(); }.wrap(null); | 217 var preventDefault = function(event) { event.preventDefault(); }.wrap(null); |
| 218 | 218 |
| 219 document.ondragstart = preventDefault; | 219 document.ondragstart = preventDefault; |
| 220 | 220 |
| 221 var maximizeButton = queryRequiredElement('.maximize-button'); | |
| 222 maximizeButton.addEventListener( | |
| 223 'click', | |
| 224 function(event) { | |
| 225 var appWindow = chrome.app.window.current(); | |
| 226 if (appWindow.isMaximized()) | |
| 227 appWindow.restore(); | |
| 228 else | |
| 229 appWindow.maximize(); | |
| 230 event.stopPropagation(); | |
| 231 }.wrap(null)); | |
| 232 maximizeButton.addEventListener('mousedown', preventDefault); | |
| 233 | |
| 234 var minimizeButton = queryRequiredElement('.minimize-button'); | |
| 235 minimizeButton.addEventListener( | |
| 236 'click', | |
| 237 function(event) { | |
| 238 chrome.app.window.current().minimize(); | |
| 239 event.stopPropagation(); | |
| 240 }.wrap(null)); | |
| 241 minimizeButton.addEventListener('mousedown', preventDefault); | |
| 242 | |
| 243 var closeButton = queryRequiredElement('.close-button'); | |
| 244 closeButton.addEventListener( | |
| 245 'click', | |
| 246 function(event) { | |
| 247 window.close(); | |
| 248 event.stopPropagation(); | |
| 249 }.wrap(null)); | |
| 250 closeButton.addEventListener('mousedown', preventDefault); | |
| 251 | |
| 252 cr.ui.decorate(getRequiredElement('cast-menu'), cr.ui.Menu); | 221 cr.ui.decorate(getRequiredElement('cast-menu'), cr.ui.Menu); |
| 253 | 222 |
| 254 this.controls_ = new FullWindowVideoControls( | 223 this.controls_ = new FullWindowVideoControls( |
| 255 getRequiredElement('video-player'), | 224 getRequiredElement('video-player'), |
| 256 getRequiredElement('video-container'), | 225 getRequiredElement('video-container'), |
| 257 getRequiredElement('controls')); | 226 getRequiredElement('controls')); |
| 258 | 227 |
| 259 var reloadVideo = function(e) { | 228 var reloadVideo = function(e) { |
| 260 if (this.controls_.decodeErrorOccured && | 229 if (this.controls_.decodeErrorOccured && |
| 261 // Ignore shortcut keys | 230 // Ignore shortcut keys |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 * @param {!FileEntry} video Entry of the video to be played. | 270 * @param {!FileEntry} video Entry of the video to be played. |
| 302 * @param {function()=} opt_callback Completion callback. | 271 * @param {function()=} opt_callback Completion callback. |
| 303 * @private | 272 * @private |
| 304 */ | 273 */ |
| 305 VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { | 274 VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { |
| 306 this.unloadVideo(true); | 275 this.unloadVideo(true); |
| 307 | 276 |
| 308 this.loadQueue_.run(function(callback) { | 277 this.loadQueue_.run(function(callback) { |
| 309 document.title = video.name; | 278 document.title = video.name; |
| 310 | 279 |
| 311 getRequiredElement('title').innerText = video.name; | |
| 312 | |
| 313 var videoPlayerElement = getRequiredElement('video-player'); | 280 var videoPlayerElement = getRequiredElement('video-player'); |
| 314 if (this.currentPos_ === (this.videos_.length - 1)) | 281 if (this.currentPos_ === (this.videos_.length - 1)) |
| 315 videoPlayerElement.setAttribute('last-video', true); | 282 videoPlayerElement.setAttribute('last-video', true); |
| 316 else | 283 else |
| 317 videoPlayerElement.removeAttribute('last-video'); | 284 videoPlayerElement.removeAttribute('last-video'); |
| 318 | 285 |
| 319 if (this.currentPos_ === 0) | 286 if (this.currentPos_ === 0) |
| 320 videoPlayerElement.setAttribute('first-video', true); | 287 videoPlayerElement.setAttribute('first-video', true); |
| 321 else | 288 else |
| 322 videoPlayerElement.removeAttribute('first-video'); | 289 videoPlayerElement.removeAttribute('first-video'); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 return new Promise(function(fulfill, reject) { | 659 return new Promise(function(fulfill, reject) { |
| 693 util.URLsToEntries(window.appState.items, function(entries) { | 660 util.URLsToEntries(window.appState.items, function(entries) { |
| 694 metrics.recordOpenVideoPlayerAction(); | 661 metrics.recordOpenVideoPlayerAction(); |
| 695 metrics.recordNumberOfOpenedFiles(entries.length); | 662 metrics.recordNumberOfOpenedFiles(entries.length); |
| 696 | 663 |
| 697 player.prepare(entries); | 664 player.prepare(entries); |
| 698 player.playFirstVideo(player, fulfill); | 665 player.playFirstVideo(player, fulfill); |
| 699 }.wrap()); | 666 }.wrap()); |
| 700 }.wrap()); | 667 }.wrap()); |
| 701 }.wrap()); | 668 }.wrap()); |
| OLD | NEW |