Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: ui/file_manager/video_player/js/video_player.js

Issue 514103002: Video Player: Close the video when the session is disconnected (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix a minor bug Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/video_player/js/video_player.js
diff --git a/ui/file_manager/video_player/js/video_player.js b/ui/file_manager/video_player/js/video_player.js
index dc69257645bc0653403a51548d6c99595cb84d3f..38e16057b3d0fe46f52a77d79cf0e9cd7e6cc2ac 100644
--- a/ui/file_manager/video_player/js/video_player.js
+++ b/ui/file_manager/video_player/js/video_player.js
@@ -159,6 +159,8 @@ function VideoPlayer() {
this.loadQueue_ = new AsyncUtil.Queue();
+ this.onCastSessionUpdateBound_ = this.onCastSessionUpdate_.wrap(this);
+
Object.seal(this);
}
@@ -331,6 +333,8 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) {
chrome.cast.requestSession(
fulfill, reject, undefined, this.currentCast_.label);
}.bind(this)).then(function(session) {
+ session.addUpdateListener(this.onCastSessionUpdateBound_);
+
this.currentSession_ = session;
this.videoElement_ = new CastVideoElement(media, session);
this.controls.attachMedia(this.videoElement_);
@@ -413,6 +417,7 @@ VideoPlayer.prototype.unloadVideo = function(opt_keepSession) {
if (!opt_keepSession && this.currentSession_) {
this.currentSession_.stop(callback, callback);
+ this.currentSession_.removeUpdateListener(this.onCastSessionUpdateBound_);
this.currentSession_ = null;
} else {
callback();
@@ -579,12 +584,23 @@ VideoPlayer.prototype.updateCheckOnCastMenu_ = function() {
*/
VideoPlayer.prototype.onCurrentCastDisappear_ = function() {
this.currentCast_ = null;
+ this.currentSession_.removeUpdateListener(this.onCastSessionUpdateBound_);
this.currentSession_ = null;
this.controls.showErrorMessage('GALLERY_VIDEO_DECODING_ERROR');
this.unloadVideo();
};
/**
+ * This method should be called when the session is updated.
+ * @param {boolean} alive Whether the session is alive or not.
+ * @private
+ */
+VideoPlayer.prototype.onCastSessionUpdate_ = function(alive) {
+ if (!alive)
+ this.unloadVideo();
+};
+
+/**
* Initialize the list of videos.
* @param {function(Array.<Object>)} callback Called with the video list when
* it is ready.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698