From ffc2a47d0a44c41e6663f6c36016efeb4f7100c7 Mon Sep 17 00:00:00 2001 From: olly Date: Tue, 13 Apr 2021 14:30:18 +0100 Subject: [PATCH] Pause and resume GLSurfaceView instances in player views This is the right thing to do, as per the GLSurfaceView documentation. This adds (previously omitted) calls to VideoDecoderGLSurfaceView. PiperOrigin-RevId: 368202523 --- .../android/exoplayer2/ui/PlayerView.java | 17 +++++++++-------- .../android/exoplayer2/ui/StyledPlayerView.java | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java index 0191c7c6b5..5da2d2f7d5 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java @@ -25,6 +25,7 @@ import android.graphics.Matrix; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.opengl.GLSurfaceView; import android.os.Looper; import android.util.AttributeSet; import android.view.KeyEvent; @@ -1151,28 +1152,28 @@ public class PlayerView extends FrameLayout implements AdViewProvider { } /** - * Should be called when the player is visible to the user and if {@code surface_type} is {@code - * spherical_gl_surface_view}. It is the counterpart to {@link #onPause()}. + * Should be called when the player is visible to the user, if the {@code surface_type} extends + * {@link GLSurfaceView}. It is the counterpart to {@link #onPause()}. * *

This method should typically be called in {@code Activity.onStart()}, or {@code * Activity.onResume()} for API versions <= 23. */ public void onResume() { - if (surfaceView instanceof SphericalGLSurfaceView) { - ((SphericalGLSurfaceView) surfaceView).onResume(); + if (surfaceView instanceof GLSurfaceView) { + ((GLSurfaceView) surfaceView).onResume(); } } /** - * Should be called when the player is no longer visible to the user and if {@code surface_type} - * is {@code spherical_gl_surface_view}. It is the counterpart to {@link #onResume()}. + * Should be called when the player is no longer visible to the user, if the {@code surface_type} + * extends {@link GLSurfaceView}. It is the counterpart to {@link #onResume()}. * *

This method should typically be called in {@code Activity.onStop()}, or {@code * Activity.onPause()} for API versions <= 23. */ public void onPause() { - if (surfaceView instanceof SphericalGLSurfaceView) { - ((SphericalGLSurfaceView) surfaceView).onPause(); + if (surfaceView instanceof GLSurfaceView) { + ((GLSurfaceView) surfaceView).onPause(); } } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java index cd9adf7421..ebd28f9e15 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java @@ -27,6 +27,7 @@ import android.graphics.Matrix; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.opengl.GLSurfaceView; import android.os.Looper; import android.util.AttributeSet; import android.view.KeyEvent; @@ -1169,28 +1170,28 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { } /** - * Should be called when the player is visible to the user and if {@code surface_type} is {@code - * spherical_gl_surface_view}. It is the counterpart to {@link #onPause()}. + * Should be called when the player is visible to the user, if the {@code surface_type} extends + * {@link GLSurfaceView}. It is the counterpart to {@link #onPause()}. * *

This method should typically be called in {@code Activity.onStart()}, or {@code * Activity.onResume()} for API versions <= 23. */ public void onResume() { - if (surfaceView instanceof SphericalGLSurfaceView) { - ((SphericalGLSurfaceView) surfaceView).onResume(); + if (surfaceView instanceof GLSurfaceView) { + ((GLSurfaceView) surfaceView).onResume(); } } /** - * Should be called when the player is no longer visible to the user and if {@code surface_type} - * is {@code spherical_gl_surface_view}. It is the counterpart to {@link #onResume()}. + * Should be called when the player is no longer visible to the user, if the {@code surface_type} + * extends {@link GLSurfaceView}. It is the counterpart to {@link #onResume()}. * *

This method should typically be called in {@code Activity.onStop()}, or {@code * Activity.onPause()} for API versions <= 23. */ public void onPause() { - if (surfaceView instanceof SphericalGLSurfaceView) { - ((SphericalGLSurfaceView) surfaceView).onPause(); + if (surfaceView instanceof GLSurfaceView) { + ((GLSurfaceView) surfaceView).onPause(); } }