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
This commit is contained in:
olly 2021-04-13 14:30:18 +01:00 committed by Andrew Lewis
parent 72c77875e4
commit ffc2a47d0a
2 changed files with 18 additions and 16 deletions

View File

@ -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()}.
*
* <p>This method should typically be called in {@code Activity.onStart()}, or {@code
* Activity.onResume()} for API versions &lt;= 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()}.
*
* <p>This method should typically be called in {@code Activity.onStop()}, or {@code
* Activity.onPause()} for API versions &lt;= 23.
*/
public void onPause() {
if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).onPause();
if (surfaceView instanceof GLSurfaceView) {
((GLSurfaceView) surfaceView).onPause();
}
}

View File

@ -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()}.
*
* <p>This method should typically be called in {@code Activity.onStart()}, or {@code
* Activity.onResume()} for API versions &lt;= 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()}.
*
* <p>This method should typically be called in {@code Activity.onStop()}, or {@code
* Activity.onPause()} for API versions &lt;= 23.
*/
public void onPause() {
if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).onPause();
if (surfaceView instanceof GLSurfaceView) {
((GLSurfaceView) surfaceView).onPause();
}
}