From c48ea68e7ed77cdab0bba9b270e96f90744e1ab7 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Tue, 18 Jan 2022 11:57:58 -0500 Subject: [PATCH] Keep screen on during video playback. --- .../org/thoughtcrime/securesms/video/VideoPlayer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/video/VideoPlayer.java b/app/src/main/java/org/thoughtcrime/securesms/video/VideoPlayer.java index fd20e748e..dc8d5cd45 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/video/VideoPlayer.java +++ b/app/src/main/java/org/thoughtcrime/securesms/video/VideoPlayer.java @@ -244,6 +244,9 @@ public class VideoPlayer extends FrameLayout { public void setWindow(@Nullable Window window) { this.window = window; + if (exoPlayerListener != null) { + exoPlayerListener.setWindow(window); + } } public void setPlayerStateCallbacks(@Nullable PlayerStateCallback playerStateCallback) { @@ -272,7 +275,7 @@ public class VideoPlayer extends FrameLayout { private static class ExoPlayerListener implements Player.Listener { private final VideoPlayer videoPlayer; - private final Window window; + private Window window; private final PlayerStateCallback playerStateCallback; private final PlayerPositionDiscontinuityCallback playerPositionDiscontinuityCallback; @@ -297,6 +300,10 @@ public class VideoPlayer extends FrameLayout { onPlaybackStateChanged(videoPlayer.exoPlayer.getPlayWhenReady(), playbackState); } + public void setWindow(Window window) { + this.window = window; + } + private void onPlaybackStateChanged(boolean playWhenReady, int playbackState) { switch (playbackState) { case Player.STATE_IDLE: