Core/UI decoupling: Remove setUseSensorRotation from views
Other properties of SphericalGLSurfaceView (e.g., setDefaultStereoMode) are not plumbed through the PlayerView components, and it doesn't scale to plumb through all properties of all of the SurfaceView types. Applications can instead do: ``` ((SphericalGLSurfaceView) playerView.getVideoSurfaceView()) .setUseSensorRotation(useSensorRotation); ``` PiperOrigin-RevId: 368196537
This commit is contained in:
parent
353912c8e1
commit
72c77875e4
@ -31,6 +31,10 @@
|
||||
* Fix `StyledPlayerControlView` to stay in full mode (rather than minimal
|
||||
mode) when possible
|
||||
([#8763](https://github.com/google/ExoPlayer/issues/8763)).
|
||||
* Remove `setUseSensorRotation` from `PlayerView` and `StyledPlayerView`.
|
||||
Instead, cast the view returned by `getVideoSurfaceView` to
|
||||
`SphericalGLSurfaceView`, and then call `setUseSensorRotation` on the
|
||||
`SphericalGLSurfaceView` directly.
|
||||
* Audio:
|
||||
* Report unexpected discontinuities in
|
||||
`AnalyticsListener.onAudioSinkError`
|
||||
|
@ -146,12 +146,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
* <li>Corresponding method: None
|
||||
* <li>Default: {@code surface_view}
|
||||
* </ul>
|
||||
* <li><b>{@code use_sensor_rotation}</b> - Whether to use the orientation sensor for rotation
|
||||
* during spherical playbacks (if available).
|
||||
* <ul>
|
||||
* <li>Corresponding method: {@link #setUseSensorRotation(boolean)}
|
||||
* <li>Default: {@code true}
|
||||
* </ul>
|
||||
* <li><b>{@code shutter_background_color}</b> - The background color of the {@code exo_shutter}
|
||||
* view.
|
||||
* <ul>
|
||||
@ -315,7 +309,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
@Nullable private Drawable defaultArtwork;
|
||||
private @ShowBuffering int showBuffering;
|
||||
private boolean keepContentOnPlayerReset;
|
||||
private boolean useSensorRotation;
|
||||
@Nullable private ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider;
|
||||
@Nullable private CharSequence customErrorMessage;
|
||||
private int controllerShowTimeoutMs;
|
||||
@ -375,7 +368,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
boolean controllerAutoShow = true;
|
||||
boolean controllerHideDuringAds = true;
|
||||
int showBuffering = SHOW_BUFFERING_NEVER;
|
||||
useSensorRotation = true;
|
||||
if (attrs != null) {
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PlayerView, 0, 0);
|
||||
try {
|
||||
@ -399,8 +391,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
R.styleable.PlayerView_keep_content_on_player_reset, keepContentOnPlayerReset);
|
||||
controllerHideDuringAds =
|
||||
a.getBoolean(R.styleable.PlayerView_hide_during_ads, controllerHideDuringAds);
|
||||
useSensorRotation =
|
||||
a.getBoolean(R.styleable.PlayerView_use_sensor_rotation, useSensorRotation);
|
||||
} finally {
|
||||
a.recycle();
|
||||
}
|
||||
@ -433,7 +423,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
case SURFACE_TYPE_SPHERICAL_GL_SURFACE_VIEW:
|
||||
SphericalGLSurfaceView sphericalGLSurfaceView = new SphericalGLSurfaceView(context);
|
||||
sphericalGLSurfaceView.setSingleTapListener(componentListener);
|
||||
sphericalGLSurfaceView.setUseSensorRotation(useSensorRotation);
|
||||
surfaceView = sphericalGLSurfaceView;
|
||||
break;
|
||||
case SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
|
||||
@ -742,22 +731,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to use the orientation sensor for rotation during spherical playbacks (if
|
||||
* available)
|
||||
*
|
||||
* @param useSensorRotation Whether to use the orientation sensor for rotation during spherical
|
||||
* playbacks.
|
||||
*/
|
||||
public void setUseSensorRotation(boolean useSensorRotation) {
|
||||
if (this.useSensorRotation != useSensorRotation) {
|
||||
this.useSensorRotation = useSensorRotation;
|
||||
if (surfaceView instanceof SphericalGLSurfaceView) {
|
||||
((SphericalGLSurfaceView) surfaceView).setUseSensorRotation(useSensorRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether a buffering spinner is displayed when the player is in the buffering state. The
|
||||
* buffering spinner is not displayed by default.
|
||||
|
@ -148,12 +148,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
* <li>Corresponding method: None
|
||||
* <li>Default: {@code surface_view}
|
||||
* </ul>
|
||||
* <li><b>{@code use_sensor_rotation}</b> - Whether to use the orientation sensor for rotation
|
||||
* during spherical playbacks (if available).
|
||||
* <ul>
|
||||
* <li>Corresponding method: {@link #setUseSensorRotation(boolean)}
|
||||
* <li>Default: {@code true}
|
||||
* </ul>
|
||||
* <li><b>{@code shutter_background_color}</b> - The background color of the {@code exo_shutter}
|
||||
* view.
|
||||
* <ul>
|
||||
@ -317,7 +311,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||
@Nullable private Drawable defaultArtwork;
|
||||
private @ShowBuffering int showBuffering;
|
||||
private boolean keepContentOnPlayerReset;
|
||||
private boolean useSensorRotation;
|
||||
@Nullable private ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider;
|
||||
@Nullable private CharSequence customErrorMessage;
|
||||
private int controllerShowTimeoutMs;
|
||||
@ -377,7 +370,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||
boolean controllerAutoShow = true;
|
||||
boolean controllerHideDuringAds = true;
|
||||
int showBuffering = SHOW_BUFFERING_NEVER;
|
||||
useSensorRotation = true;
|
||||
if (attrs != null) {
|
||||
TypedArray a =
|
||||
context.getTheme().obtainStyledAttributes(attrs, R.styleable.StyledPlayerView, 0, 0);
|
||||
@ -406,8 +398,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||
keepContentOnPlayerReset);
|
||||
controllerHideDuringAds =
|
||||
a.getBoolean(R.styleable.StyledPlayerView_hide_during_ads, controllerHideDuringAds);
|
||||
useSensorRotation =
|
||||
a.getBoolean(R.styleable.StyledPlayerView_use_sensor_rotation, useSensorRotation);
|
||||
} finally {
|
||||
a.recycle();
|
||||
}
|
||||
@ -440,7 +430,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||
case SURFACE_TYPE_SPHERICAL_GL_SURFACE_VIEW:
|
||||
SphericalGLSurfaceView sphericalGLSurfaceView = new SphericalGLSurfaceView(context);
|
||||
sphericalGLSurfaceView.setSingleTapListener(componentListener);
|
||||
sphericalGLSurfaceView.setUseSensorRotation(useSensorRotation);
|
||||
surfaceView = sphericalGLSurfaceView;
|
||||
break;
|
||||
case SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
|
||||
@ -751,22 +740,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to use the orientation sensor for rotation during spherical playbacks (if
|
||||
* available)
|
||||
*
|
||||
* @param useSensorRotation Whether to use the orientation sensor for rotation during spherical
|
||||
* playbacks.
|
||||
*/
|
||||
public void setUseSensorRotation(boolean useSensorRotation) {
|
||||
if (this.useSensorRotation != useSensorRotation) {
|
||||
this.useSensorRotation = useSensorRotation;
|
||||
if (surfaceView instanceof SphericalGLSurfaceView) {
|
||||
((SphericalGLSurfaceView) surfaceView).setUseSensorRotation(useSensorRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether a buffering spinner is displayed when the player is in the buffering state. The
|
||||
* buffering spinner is not displayed by default.
|
||||
|
@ -54,7 +54,6 @@
|
||||
<enum name="always" value="2"/>
|
||||
</attr>
|
||||
<attr name="keep_content_on_player_reset" format="boolean"/>
|
||||
<attr name="use_sensor_rotation" format="boolean"/>
|
||||
<attr name="player_layout_id" format="reference"/>
|
||||
|
||||
<!-- PlayerControlView and StyledPlayerControlView attributes -->
|
||||
@ -104,7 +103,6 @@
|
||||
<attr name="auto_show"/>
|
||||
<attr name="show_buffering"/>
|
||||
<attr name="keep_content_on_player_reset"/>
|
||||
<attr name="use_sensor_rotation"/>
|
||||
<attr name="player_layout_id"/>
|
||||
<attr name="surface_type"/>
|
||||
<!-- AspectRatioFrameLayout attributes -->
|
||||
@ -143,7 +141,6 @@
|
||||
<attr name="auto_show"/>
|
||||
<attr name="show_buffering"/>
|
||||
<attr name="keep_content_on_player_reset"/>
|
||||
<attr name="use_sensor_rotation"/>
|
||||
<attr name="player_layout_id"/>
|
||||
<attr name="surface_type"/>
|
||||
<!-- AspectRatioFrameLayout attributes -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user