Commit 820765f8 authored by yoshiki's avatar yoshiki Committed by Commit bot

Video Player: Keep the display awake during playing a video

BUG=410726
TEST=manual

Review URL: https://codereview.chromium.org/542643003

Cr-Commit-Position: refs/heads/master@{#293707}
parent 4ce7861c
...@@ -269,6 +269,9 @@ VideoPlayer.prototype.prepare = function(videos) { ...@@ -269,6 +269,9 @@ VideoPlayer.prototype.prepare = function(videos) {
* Unloads the player. * Unloads the player.
*/ */
function unload() { function unload() {
// Releases keep awake just in case (should be released on unloading video).
chrome.power.releaseKeepAwake();
if (!player.controls || !player.controls.getMedia()) if (!player.controls || !player.controls.getMedia())
return; return;
...@@ -386,6 +389,14 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { ...@@ -386,6 +389,14 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) {
}.wrap(this, this.currentPos_); }.wrap(this, this.currentPos_);
this.videoElement_.addEventListener('loadedmetadata', handler); 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(); this.videoElement_.load();
callback(); callback();
}.bind(this)). }.bind(this)).
...@@ -415,6 +426,8 @@ VideoPlayer.prototype.playFirstVideo = function() { ...@@ -415,6 +426,8 @@ VideoPlayer.prototype.playFirstVideo = function() {
*/ */
VideoPlayer.prototype.unloadVideo = function(opt_keepSession) { VideoPlayer.prototype.unloadVideo = function(opt_keepSession) {
this.loadQueue_.run(function(callback) { this.loadQueue_.run(function(callback) {
chrome.power.releaseKeepAwake();
if (this.videoElement_) { if (this.videoElement_) {
// If the element has dispose method, call it (CastVideoElement has it). // If the element has dispose method, call it (CastVideoElement has it).
if (this.videoElement_.dispose) if (this.videoElement_.dispose)
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"fileBrowserPrivate", "fileBrowserPrivate",
"fullscreen", "fullscreen",
"mediaPlayerPrivate", "mediaPlayerPrivate",
"power",
"storage", "storage",
"chrome://resources/", "chrome://resources/",
"chrome://theme/" "chrome://theme/"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment