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. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 * Handles playback (decoder) errors. | 104 * Handles playback (decoder) errors. |
105 * @param {MediaError} error Error object. | 105 * @param {MediaError} error Error object. |
106 * @private | 106 * @private |
107 */ | 107 */ |
108 FullWindowVideoControls.prototype.onPlaybackError_ = function(error) { | 108 FullWindowVideoControls.prototype.onPlaybackError_ = function(error) { |
109 if (error.target && error.target.error && | 109 if (error.target && error.target.error && |
110 error.target.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) { | 110 error.target.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) { |
111 if (this.casting) | 111 if (this.casting) |
112 this.showErrorMessage('VIDEO_PLAYER_VIDEO_FILE_UNSUPPORTED_FOR_CAST'); | 112 this.showErrorMessage('VIDEO_PLAYER_VIDEO_FILE_UNSUPPORTED_FOR_CAST'); |
113 else | 113 else |
114 this.showErrorMessage('GALLERY_VIDEO_ERROR'); | 114 this.showErrorMessage('VIDEO_PLAYER_VIDEO_FILE_UNSUPPORTED'); |
115 this.decodeErrorOccured = false; | 115 this.decodeErrorOccured = false; |
116 } else { | 116 } else { |
117 this.showErrorMessage('GALLERY_VIDEO_DECODING_ERROR'); | 117 this.showErrorMessage('VIDEO_PLAYER_PLAYBACK_ERROR'); |
118 this.decodeErrorOccured = true; | 118 this.decodeErrorOccured = true; |
119 } | 119 } |
120 | 120 |
121 // Disable inactivity watcher, and disable the ui, by hiding tools manually. | 121 // Disable inactivity watcher, and disable the ui, by hiding tools manually. |
122 this.inactivityWatcher.disabled = true; | 122 this.inactivityWatcher.disabled = true; |
123 document.querySelector('#video-player').setAttribute('disabled', 'true'); | 123 document.querySelector('#video-player').setAttribute('disabled', 'true'); |
124 | 124 |
125 // Detach the video element, since it may be unreliable and reset stored | 125 // Detach the video element, since it may be unreliable and reset stored |
126 // current playback time. | 126 // current playback time. |
127 this.cleanup(); | 127 this.cleanup(); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 }.wrap()); | 388 }.wrap()); |
389 | 389 |
390 this.videoElement_.load(); | 390 this.videoElement_.load(); |
391 callback(); | 391 callback(); |
392 }.bind(this)) | 392 }.bind(this)) |
393 // In case of error. | 393 // In case of error. |
394 .catch(function(error) { | 394 .catch(function(error) { |
395 videoPlayerElement.removeAttribute('loading'); | 395 videoPlayerElement.removeAttribute('loading'); |
396 console.error('Failed to initialize the video element.', | 396 console.error('Failed to initialize the video element.', |
397 error.stack || error); | 397 error.stack || error); |
398 this.controls_.showErrorMessage('GALLERY_VIDEO_ERROR'); | 398 this.controls_.showErrorMessage( |
| 399 'VIDEO_PLAYER_VIDEO_FILE_UNSUPPORTED'); |
399 callback(); | 400 callback(); |
400 }.bind(this)); | 401 }.bind(this)); |
401 }.wrap(this)); | 402 }.wrap(this)); |
402 }; | 403 }; |
403 | 404 |
404 /** | 405 /** |
405 * Plays the first video. | 406 * Plays the first video. |
406 */ | 407 */ |
407 VideoPlayer.prototype.playFirstVideo = function() { | 408 VideoPlayer.prototype.playFirstVideo = function() { |
408 this.currentPos_ = 0; | 409 this.currentPos_ = 0; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 /** | 607 /** |
607 * Called when the current cast is disappear from the cast list. | 608 * Called when the current cast is disappear from the cast list. |
608 * @private | 609 * @private |
609 */ | 610 */ |
610 VideoPlayer.prototype.onCurrentCastDisappear_ = function() { | 611 VideoPlayer.prototype.onCurrentCastDisappear_ = function() { |
611 this.currentCast_ = null; | 612 this.currentCast_ = null; |
612 if (this.currentSession_) { | 613 if (this.currentSession_) { |
613 this.currentSession_.removeUpdateListener(this.onCastSessionUpdateBound_); | 614 this.currentSession_.removeUpdateListener(this.onCastSessionUpdateBound_); |
614 this.currentSession_ = null; | 615 this.currentSession_ = null; |
615 } | 616 } |
616 this.controls.showErrorMessage('GALLERY_VIDEO_DECODING_ERROR'); | 617 this.controls.showErrorMessage('VIDEO_PLAYER_PLAYBACK_ERROR'); |
617 this.unloadVideo(); | 618 this.unloadVideo(); |
618 }; | 619 }; |
619 | 620 |
620 /** | 621 /** |
621 * This method should be called when the session is updated. | 622 * This method should be called when the session is updated. |
622 * @param {boolean} alive Whether the session is alive or not. | 623 * @param {boolean} alive Whether the session is alive or not. |
623 * @private | 624 * @private |
624 */ | 625 */ |
625 VideoPlayer.prototype.onCastSessionUpdate_ = function(alive) { | 626 VideoPlayer.prototype.onCastSessionUpdate_ = function(alive) { |
626 if (!alive) | 627 if (!alive) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 var initPromise = Promise.all( | 666 var initPromise = Promise.all( |
666 [new Promise(initVideos.wrap(null)), | 667 [new Promise(initVideos.wrap(null)), |
667 new Promise(initStrings.wrap(null)), | 668 new Promise(initStrings.wrap(null)), |
668 new Promise(util.addPageLoadHandler.wrap(null))]); | 669 new Promise(util.addPageLoadHandler.wrap(null))]); |
669 | 670 |
670 initPromise.then(function(results) { | 671 initPromise.then(function(results) { |
671 var videos = results[0]; | 672 var videos = results[0]; |
672 player.prepare(videos); | 673 player.prepare(videos); |
673 return new Promise(player.playFirstVideo.wrap(player)); | 674 return new Promise(player.playFirstVideo.wrap(player)); |
674 }.wrap(null)); | 675 }.wrap(null)); |
OLD | NEW |