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

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

Issue 542643003: Video Player: Keep the display awake during playing a video (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop keepawake on pause, and resume it on play. Created 6 years, 3 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 | ui/file_manager/video_player/manifest.json » ('j') | 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 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)
« no previous file with comments | « no previous file | ui/file_manager/video_player/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698