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) {
* 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;
......@@ -386,6 +389,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)).
......@@ -415,6 +426,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)
......
......@@ -23,6 +23,7 @@
"fileBrowserPrivate",
"fullscreen",
"mediaPlayerPrivate",
"power",
"storage",
"chrome://resources/",
"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