mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Core/UI decoupling: Remove SphericalGLSurfaceView cast
PiperOrigin-RevId: 368420961
This commit is contained in:
parent
c50084e7ba
commit
bd654279d7
2 changed files with 26 additions and 26 deletions
|
|
@ -295,6 +295,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
@Nullable private final AspectRatioFrameLayout contentFrame;
|
@Nullable private final AspectRatioFrameLayout contentFrame;
|
||||||
@Nullable private final View shutterView;
|
@Nullable private final View shutterView;
|
||||||
@Nullable private final View surfaceView;
|
@Nullable private final View surfaceView;
|
||||||
|
private final boolean surfaceViewIgnoresVideoAspectRatio;
|
||||||
@Nullable private final ImageView artworkView;
|
@Nullable private final ImageView artworkView;
|
||||||
@Nullable private final SubtitleView subtitleView;
|
@Nullable private final SubtitleView subtitleView;
|
||||||
@Nullable private final View bufferingView;
|
@Nullable private final View bufferingView;
|
||||||
|
|
@ -339,6 +340,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
contentFrame = null;
|
contentFrame = null;
|
||||||
shutterView = null;
|
shutterView = null;
|
||||||
surfaceView = null;
|
surfaceView = null;
|
||||||
|
surfaceViewIgnoresVideoAspectRatio = false;
|
||||||
artworkView = null;
|
artworkView = null;
|
||||||
subtitleView = null;
|
subtitleView = null;
|
||||||
bufferingView = null;
|
bufferingView = null;
|
||||||
|
|
@ -413,6 +415,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a surface view and insert it into the content frame, if there is one.
|
// Create a surface view and insert it into the content frame, if there is one.
|
||||||
|
boolean surfaceViewIgnoresVideoAspectRatio = false;
|
||||||
if (contentFrame != null && surfaceType != SURFACE_TYPE_NONE) {
|
if (contentFrame != null && surfaceType != SURFACE_TYPE_NONE) {
|
||||||
ViewGroup.LayoutParams params =
|
ViewGroup.LayoutParams params =
|
||||||
new ViewGroup.LayoutParams(
|
new ViewGroup.LayoutParams(
|
||||||
|
|
@ -425,6 +428,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
SphericalGLSurfaceView sphericalGLSurfaceView = new SphericalGLSurfaceView(context);
|
SphericalGLSurfaceView sphericalGLSurfaceView = new SphericalGLSurfaceView(context);
|
||||||
sphericalGLSurfaceView.setSingleTapListener(componentListener);
|
sphericalGLSurfaceView.setSingleTapListener(componentListener);
|
||||||
surfaceView = sphericalGLSurfaceView;
|
surfaceView = sphericalGLSurfaceView;
|
||||||
|
surfaceViewIgnoresVideoAspectRatio = true;
|
||||||
break;
|
break;
|
||||||
case SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
|
case SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
|
||||||
surfaceView = new VideoDecoderGLSurfaceView(context);
|
surfaceView = new VideoDecoderGLSurfaceView(context);
|
||||||
|
|
@ -438,6 +442,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
} else {
|
} else {
|
||||||
surfaceView = null;
|
surfaceView = null;
|
||||||
}
|
}
|
||||||
|
this.surfaceViewIgnoresVideoAspectRatio = surfaceViewIgnoresVideoAspectRatio;
|
||||||
|
|
||||||
// Ad overlay frame layout.
|
// Ad overlay frame layout.
|
||||||
adOverlayFrameLayout = findViewById(R.id.exo_ad_overlay);
|
adOverlayFrameLayout = findViewById(R.id.exo_ad_overlay);
|
||||||
|
|
@ -1178,22 +1183,16 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when there's a change in the aspect ratio of the content being displayed. The default
|
* Called when there's a change in the desired aspect ratio of the content frame. The default
|
||||||
* implementation sets the aspect ratio of the content frame to that of the content, unless the
|
* implementation sets the aspect ratio of the content frame to the specified value.
|
||||||
* content view is a {@link SphericalGLSurfaceView} in which case the frame's aspect ratio is
|
|
||||||
* cleared.
|
|
||||||
*
|
*
|
||||||
* @param contentAspectRatio The aspect ratio of the content.
|
|
||||||
* @param contentFrame The content frame, or {@code null}.
|
* @param contentFrame The content frame, or {@code null}.
|
||||||
* @param contentView The view that holds the content being displayed, or {@code null}.
|
* @param aspectRatio The aspect ratio to apply.
|
||||||
*/
|
*/
|
||||||
protected void onContentAspectRatioChanged(
|
protected void onContentAspectRatioChanged(
|
||||||
float contentAspectRatio,
|
@Nullable AspectRatioFrameLayout contentFrame, float aspectRatio) {
|
||||||
@Nullable AspectRatioFrameLayout contentFrame,
|
|
||||||
@Nullable View contentView) {
|
|
||||||
if (contentFrame != null) {
|
if (contentFrame != null) {
|
||||||
contentFrame.setAspectRatio(
|
contentFrame.setAspectRatio(aspectRatio);
|
||||||
contentView instanceof SphericalGLSurfaceView ? 0 : contentAspectRatio);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1366,7 +1365,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
int drawableHeight = drawable.getIntrinsicHeight();
|
int drawableHeight = drawable.getIntrinsicHeight();
|
||||||
if (drawableWidth > 0 && drawableHeight > 0) {
|
if (drawableWidth > 0 && drawableHeight > 0) {
|
||||||
float artworkAspectRatio = (float) drawableWidth / drawableHeight;
|
float artworkAspectRatio = (float) drawableWidth / drawableHeight;
|
||||||
onContentAspectRatioChanged(artworkAspectRatio, contentFrame, artworkView);
|
onContentAspectRatioChanged(contentFrame, artworkAspectRatio);
|
||||||
artworkView.setImageDrawable(drawable);
|
artworkView.setImageDrawable(drawable);
|
||||||
artworkView.setVisibility(VISIBLE);
|
artworkView.setVisibility(VISIBLE);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1542,7 +1541,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
applyTextureViewRotation((TextureView) surfaceView, textureViewRotation);
|
applyTextureViewRotation((TextureView) surfaceView, textureViewRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
onContentAspectRatioChanged(videoAspectRatio, contentFrame, surfaceView);
|
onContentAspectRatioChanged(
|
||||||
|
contentFrame, surfaceViewIgnoresVideoAspectRatio ? 0 : videoAspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
@Nullable private final AspectRatioFrameLayout contentFrame;
|
@Nullable private final AspectRatioFrameLayout contentFrame;
|
||||||
@Nullable private final View shutterView;
|
@Nullable private final View shutterView;
|
||||||
@Nullable private final View surfaceView;
|
@Nullable private final View surfaceView;
|
||||||
|
private final boolean surfaceViewIgnoresVideoAspectRatio;
|
||||||
@Nullable private final ImageView artworkView;
|
@Nullable private final ImageView artworkView;
|
||||||
@Nullable private final SubtitleView subtitleView;
|
@Nullable private final SubtitleView subtitleView;
|
||||||
@Nullable private final View bufferingView;
|
@Nullable private final View bufferingView;
|
||||||
|
|
@ -341,6 +342,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
contentFrame = null;
|
contentFrame = null;
|
||||||
shutterView = null;
|
shutterView = null;
|
||||||
surfaceView = null;
|
surfaceView = null;
|
||||||
|
surfaceViewIgnoresVideoAspectRatio = false;
|
||||||
artworkView = null;
|
artworkView = null;
|
||||||
subtitleView = null;
|
subtitleView = null;
|
||||||
bufferingView = null;
|
bufferingView = null;
|
||||||
|
|
@ -420,6 +422,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a surface view and insert it into the content frame, if there is one.
|
// Create a surface view and insert it into the content frame, if there is one.
|
||||||
|
boolean surfaceViewIgnoresVideoAspectRatio = false;
|
||||||
if (contentFrame != null && surfaceType != SURFACE_TYPE_NONE) {
|
if (contentFrame != null && surfaceType != SURFACE_TYPE_NONE) {
|
||||||
ViewGroup.LayoutParams params =
|
ViewGroup.LayoutParams params =
|
||||||
new ViewGroup.LayoutParams(
|
new ViewGroup.LayoutParams(
|
||||||
|
|
@ -432,6 +435,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
SphericalGLSurfaceView sphericalGLSurfaceView = new SphericalGLSurfaceView(context);
|
SphericalGLSurfaceView sphericalGLSurfaceView = new SphericalGLSurfaceView(context);
|
||||||
sphericalGLSurfaceView.setSingleTapListener(componentListener);
|
sphericalGLSurfaceView.setSingleTapListener(componentListener);
|
||||||
surfaceView = sphericalGLSurfaceView;
|
surfaceView = sphericalGLSurfaceView;
|
||||||
|
surfaceViewIgnoresVideoAspectRatio = true;
|
||||||
break;
|
break;
|
||||||
case SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
|
case SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
|
||||||
surfaceView = new VideoDecoderGLSurfaceView(context);
|
surfaceView = new VideoDecoderGLSurfaceView(context);
|
||||||
|
|
@ -445,6 +449,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
} else {
|
} else {
|
||||||
surfaceView = null;
|
surfaceView = null;
|
||||||
}
|
}
|
||||||
|
this.surfaceViewIgnoresVideoAspectRatio = surfaceViewIgnoresVideoAspectRatio;
|
||||||
|
|
||||||
// Ad overlay frame layout.
|
// Ad overlay frame layout.
|
||||||
adOverlayFrameLayout = findViewById(R.id.exo_ad_overlay);
|
adOverlayFrameLayout = findViewById(R.id.exo_ad_overlay);
|
||||||
|
|
@ -1196,22 +1201,16 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when there's a change in the aspect ratio of the content being displayed. The default
|
* Called when there's a change in the desired aspect ratio of the content frame. The default
|
||||||
* implementation sets the aspect ratio of the content frame to that of the content, unless the
|
* implementation sets the aspect ratio of the content frame to the specified value.
|
||||||
* content view is a {@link SphericalGLSurfaceView} in which case the frame's aspect ratio is
|
|
||||||
* cleared.
|
|
||||||
*
|
*
|
||||||
* @param contentAspectRatio The aspect ratio of the content.
|
|
||||||
* @param contentFrame The content frame, or {@code null}.
|
* @param contentFrame The content frame, or {@code null}.
|
||||||
* @param contentView The view that holds the content being displayed, or {@code null}.
|
* @param aspectRatio The aspect ratio to apply.
|
||||||
*/
|
*/
|
||||||
protected void onContentAspectRatioChanged(
|
protected void onContentAspectRatioChanged(
|
||||||
float contentAspectRatio,
|
@Nullable AspectRatioFrameLayout contentFrame, float aspectRatio) {
|
||||||
@Nullable AspectRatioFrameLayout contentFrame,
|
|
||||||
@Nullable View contentView) {
|
|
||||||
if (contentFrame != null) {
|
if (contentFrame != null) {
|
||||||
contentFrame.setAspectRatio(
|
contentFrame.setAspectRatio(aspectRatio);
|
||||||
contentView instanceof SphericalGLSurfaceView ? 0 : contentAspectRatio);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1388,7 +1387,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
int drawableHeight = drawable.getIntrinsicHeight();
|
int drawableHeight = drawable.getIntrinsicHeight();
|
||||||
if (drawableWidth > 0 && drawableHeight > 0) {
|
if (drawableWidth > 0 && drawableHeight > 0) {
|
||||||
float artworkAspectRatio = (float) drawableWidth / drawableHeight;
|
float artworkAspectRatio = (float) drawableWidth / drawableHeight;
|
||||||
onContentAspectRatioChanged(artworkAspectRatio, contentFrame, artworkView);
|
onContentAspectRatioChanged(contentFrame, artworkAspectRatio);
|
||||||
artworkView.setImageDrawable(drawable);
|
artworkView.setImageDrawable(drawable);
|
||||||
artworkView.setVisibility(VISIBLE);
|
artworkView.setVisibility(VISIBLE);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1564,7 +1563,8 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
applyTextureViewRotation((TextureView) surfaceView, textureViewRotation);
|
applyTextureViewRotation((TextureView) surfaceView, textureViewRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
onContentAspectRatioChanged(videoAspectRatio, contentFrame, surfaceView);
|
onContentAspectRatioChanged(
|
||||||
|
contentFrame, surfaceViewIgnoresVideoAspectRatio ? 0 : videoAspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue