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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * @param {Element} playerContainer Main container. | 8 * @param {Element} playerContainer Main container. |
9 * @param {Element} videoContainer Container for the video element. | 9 * @param {Element} videoContainer Container for the video element. |
10 * @param {Element} controlsContainer Container for video controls. | 10 * @param {Element} controlsContainer Container for video controls. |
11 * @constructor | 11 * @constructor |
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; |
| 26 |
25 this.updateStyle(); | 27 this.updateStyle(); |
26 window.addEventListener('resize', this.updateStyle.wrap(this)); | 28 window.addEventListener('resize', this.updateStyle.wrap(this)); |
27 document.addEventListener('keydown', function(e) { | 29 document.addEventListener('keydown', function(e) { |
28 switch (e.keyIdentifier) { | 30 switch (e.keyIdentifier) { |
29 case 'U+0020': // Space | 31 case 'U+0020': // Space |
30 case 'MediaPlayPause': | 32 case 'MediaPlayPause': |
31 this.togglePlayStateWithFeedback(); | 33 this.togglePlayStateWithFeedback(); |
32 break; | 34 break; |
33 case 'U+001B': // Escape | 35 case 'U+001B': // Escape |
34 util.toggleFullScreen( | 36 util.toggleFullScreen( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 }; | 102 }; |
101 | 103 |
102 /** | 104 /** |
103 * Handles playback (decoder) errors. | 105 * Handles playback (decoder) errors. |
104 * @param {MediaError} error Error object. | 106 * @param {MediaError} error Error object. |
105 * @private | 107 * @private |
106 */ | 108 */ |
107 FullWindowVideoControls.prototype.onPlaybackError_ = function(error) { | 109 FullWindowVideoControls.prototype.onPlaybackError_ = function(error) { |
108 if (error.target && error.target.error && | 110 if (error.target && error.target.error && |
109 error.target.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) { | 111 error.target.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) { |
110 this.showErrorMessage('GALLERY_VIDEO_ERROR'); | 112 if (this.casting) |
| 113 this.showErrorMessage('VIDEO_PLAYER_VIDEO_FILE_UNSUPPORTED_FOR_CAST'); |
| 114 else |
| 115 this.showErrorMessage('GALLERY_VIDEO_ERROR'); |
111 this.decodeErrorOccured = false; | 116 this.decodeErrorOccured = false; |
112 } else { | 117 } else { |
113 this.showErrorMessage('GALLERY_VIDEO_DECODING_ERROR'); | 118 this.showErrorMessage('GALLERY_VIDEO_DECODING_ERROR'); |
114 this.decodeErrorOccured = true; | 119 this.decodeErrorOccured = true; |
115 } | 120 } |
116 | 121 |
117 // Disable inactivity watcher, and disable the ui, by hiding tools manually. | 122 // Disable inactivity watcher, and disable the ui, by hiding tools manually. |
118 this.inactivityWatcher.disabled = true; | 123 this.inactivityWatcher.disabled = true; |
119 document.querySelector('#video-player').setAttribute('disabled', 'true'); | 124 document.querySelector('#video-player').setAttribute('disabled', 'true'); |
120 | 125 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 if (this.currentPos_ === 0) | 299 if (this.currentPos_ === 0) |
295 videoPlayerElement.setAttribute('first-video', true); | 300 videoPlayerElement.setAttribute('first-video', true); |
296 else | 301 else |
297 videoPlayerElement.removeAttribute('first-video'); | 302 videoPlayerElement.removeAttribute('first-video'); |
298 | 303 |
299 // Re-enables ui and hides error message if already displayed. | 304 // Re-enables ui and hides error message if already displayed. |
300 document.querySelector('#video-player').removeAttribute('disabled'); | 305 document.querySelector('#video-player').removeAttribute('disabled'); |
301 document.querySelector('#error').removeAttribute('visible'); | 306 document.querySelector('#error').removeAttribute('visible'); |
302 this.controls.inactivityWatcher.disabled = true; | 307 this.controls.inactivityWatcher.disabled = true; |
303 this.controls.decodeErrorOccured = false; | 308 this.controls.decodeErrorOccured = false; |
| 309 this.controls.casting = !!this.currentCast_; |
304 | 310 |
305 videoPlayerElement.setAttribute('loading', true); | 311 videoPlayerElement.setAttribute('loading', true); |
306 | 312 |
307 var media = new MediaManager(video.entry); | 313 var media = new MediaManager(video.entry); |
308 | 314 |
309 Promise.all([media.getThumbnail(), media.getToken()]).then( | 315 Promise.all([media.getThumbnail(), media.getToken()]).then( |
310 function(results) { | 316 function(results) { |
311 var url = results[0]; | 317 var url = results[0]; |
312 var token = results[1]; | 318 var token = results[1]; |
313 document.querySelector('#thumbnail').style.backgroundImage = | 319 document.querySelector('#thumbnail').style.backgroundImage = |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 var initPromise = Promise.all( | 653 var initPromise = Promise.all( |
648 [new Promise(initVideos.wrap(null)), | 654 [new Promise(initVideos.wrap(null)), |
649 new Promise(initStrings.wrap(null)), | 655 new Promise(initStrings.wrap(null)), |
650 new Promise(util.addPageLoadHandler.wrap(null))]); | 656 new Promise(util.addPageLoadHandler.wrap(null))]); |
651 | 657 |
652 initPromise.then(function(results) { | 658 initPromise.then(function(results) { |
653 var videos = results[0]; | 659 var videos = results[0]; |
654 player.prepare(videos); | 660 player.prepare(videos); |
655 return new Promise(player.playFirstVideo.wrap(player)); | 661 return new Promise(player.playFirstVideo.wrap(player)); |
656 }.wrap(null)); | 662 }.wrap(null)); |
OLD | NEW |