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 6ea56b53d45e457b521c4d77b698ab7bd989b7b9..ae90d0bdd9c8f654ff0d8000c8f4a22d6fdfd082 100644 |
--- a/ui/file_manager/video_player/js/video_player.js |
+++ b/ui/file_manager/video_player/js/video_player.js |
@@ -264,6 +264,9 @@ VideoPlayer.prototype.prepare = function(videos) { |
* Unloads the player. |
*/ |
function unload() { |
+ // Releases keep awake just in case (should be released on unloading video). |
+ chrome.power.releaseKeepAwake(); |
+ |
if (!player.controls || !player.controls.getMedia()) |
return; |
@@ -380,6 +383,14 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { |
}.wrap(this, this.currentPos_); |
this.videoElement_.addEventListener('loadedmetadata', handler); |
+ |
+ this.videoElement_.addEventListener('play', function() { |
+ chrome.power.requestKeepAwake('display'); |
+ }.wrap()); |
+ this.videoElement_.addEventListener('pause', function() { |
+ chrome.power.releaseKeepAwake(); |
+ }.wrap()); |
+ |
this.videoElement_.load(); |
callback(); |
}.bind(this)). |
@@ -409,6 +420,8 @@ VideoPlayer.prototype.playFirstVideo = function() { |
*/ |
VideoPlayer.prototype.unloadVideo = function(opt_keepSession) { |
this.loadQueue_.run(function(callback) { |
+ chrome.power.releaseKeepAwake(); |
+ |
if (this.videoElement_) { |
// If the element has dispose method, call it (CastVideoElement has it). |
if (this.videoElement_.dispose) |