Commit ffc2a47d by olly Committed by Andrew Lewis

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
parent 72c77875
...@@ -25,6 +25,7 @@ import android.graphics.Matrix; ...@@ -25,6 +25,7 @@ import android.graphics.Matrix;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.opengl.GLSurfaceView;
import android.os.Looper; import android.os.Looper;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.KeyEvent; import android.view.KeyEvent;
...@@ -1151,28 +1152,28 @@ public class PlayerView extends FrameLayout implements AdViewProvider { ...@@ -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 * Should be called when the player is visible to the user, if the {@code surface_type} extends
* spherical_gl_surface_view}. It is the counterpart to {@link #onPause()}. * {@link GLSurfaceView}. It is the counterpart to {@link #onPause()}.
* *
* <p>This method should typically be called in {@code Activity.onStart()}, or {@code * <p>This method should typically be called in {@code Activity.onStart()}, or {@code
* Activity.onResume()} for API versions &lt;= 23. * Activity.onResume()} for API versions &lt;= 23.
*/ */
public void onResume() { public void onResume() {
if (surfaceView instanceof SphericalGLSurfaceView) { if (surfaceView instanceof GLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).onResume(); ((GLSurfaceView) surfaceView).onResume();
} }
} }
/** /**
* Should be called when the player is no longer visible to the user and if {@code surface_type} * Should be called when the player is no longer visible to the user, if the {@code surface_type}
* is {@code spherical_gl_surface_view}. It is the counterpart to {@link #onResume()}. * extends {@link GLSurfaceView}. It is the counterpart to {@link #onResume()}.
* *
* <p>This method should typically be called in {@code Activity.onStop()}, or {@code * <p>This method should typically be called in {@code Activity.onStop()}, or {@code
* Activity.onPause()} for API versions &lt;= 23. * Activity.onPause()} for API versions &lt;= 23.
*/ */
public void onPause() { public void onPause() {
if (surfaceView instanceof SphericalGLSurfaceView) { if (surfaceView instanceof GLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).onPause(); ((GLSurfaceView) surfaceView).onPause();
} }
} }
......
...@@ -27,6 +27,7 @@ import android.graphics.Matrix; ...@@ -27,6 +27,7 @@ import android.graphics.Matrix;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.opengl.GLSurfaceView;
import android.os.Looper; import android.os.Looper;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.KeyEvent; import android.view.KeyEvent;
...@@ -1169,28 +1170,28 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { ...@@ -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 * Should be called when the player is visible to the user, if the {@code surface_type} extends
* spherical_gl_surface_view}. It is the counterpart to {@link #onPause()}. * {@link GLSurfaceView}. It is the counterpart to {@link #onPause()}.
* *
* <p>This method should typically be called in {@code Activity.onStart()}, or {@code * <p>This method should typically be called in {@code Activity.onStart()}, or {@code
* Activity.onResume()} for API versions &lt;= 23. * Activity.onResume()} for API versions &lt;= 23.
*/ */
public void onResume() { public void onResume() {
if (surfaceView instanceof SphericalGLSurfaceView) { if (surfaceView instanceof GLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).onResume(); ((GLSurfaceView) surfaceView).onResume();
} }
} }
/** /**
* Should be called when the player is no longer visible to the user and if {@code surface_type} * Should be called when the player is no longer visible to the user, if the {@code surface_type}
* is {@code spherical_gl_surface_view}. It is the counterpart to {@link #onResume()}. * extends {@link GLSurfaceView}. It is the counterpart to {@link #onResume()}.
* *
* <p>This method should typically be called in {@code Activity.onStop()}, or {@code * <p>This method should typically be called in {@code Activity.onStop()}, or {@code
* Activity.onPause()} for API versions &lt;= 23. * Activity.onPause()} for API versions &lt;= 23.
*/ */
public void onPause() { public void onPause() {
if (surfaceView instanceof SphericalGLSurfaceView) { if (surfaceView instanceof GLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).onPause(); ((GLSurfaceView) surfaceView).onPause();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment