Keep screen on during video playback.

This commit is contained in:
Cody Henthorne 2022-01-18 11:57:58 -05:00 committed by Greyson Parrelli
parent c548816daa
commit c48ea68e7e

View file

@ -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: