Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bd654279
authored
Apr 14, 2021
by
olly
Committed by
Andrew Lewis
Apr 15, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Core/UI decoupling: Remove SphericalGLSurfaceView cast
PiperOrigin-RevId: 368420961
parent
c50084e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
26 deletions
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
View file @
bd654279
...
...
@@ -295,6 +295,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
@Nullable
private
final
AspectRatioFrameLayout
contentFrame
;
@Nullable
private
final
View
shutterView
;
@Nullable
private
final
View
surfaceView
;
private
final
boolean
surfaceViewIgnoresVideoAspectRatio
;
@Nullable
private
final
ImageView
artworkView
;
@Nullable
private
final
SubtitleView
subtitleView
;
@Nullable
private
final
View
bufferingView
;
...
...
@@ -339,6 +340,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
contentFrame
=
null
;
shutterView
=
null
;
surfaceView
=
null
;
surfaceViewIgnoresVideoAspectRatio
=
false
;
artworkView
=
null
;
subtitleView
=
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.
boolean
surfaceViewIgnoresVideoAspectRatio
=
false
;
if
(
contentFrame
!=
null
&&
surfaceType
!=
SURFACE_TYPE_NONE
)
{
ViewGroup
.
LayoutParams
params
=
new
ViewGroup
.
LayoutParams
(
...
...
@@ -425,6 +428,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
SphericalGLSurfaceView
sphericalGLSurfaceView
=
new
SphericalGLSurfaceView
(
context
);
sphericalGLSurfaceView
.
setSingleTapListener
(
componentListener
);
surfaceView
=
sphericalGLSurfaceView
;
surfaceViewIgnoresVideoAspectRatio
=
true
;
break
;
case
SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
surfaceView
=
new
VideoDecoderGLSurfaceView
(
context
);
...
...
@@ -438,6 +442,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
}
else
{
surfaceView
=
null
;
}
this
.
surfaceViewIgnoresVideoAspectRatio
=
surfaceViewIgnoresVideoAspectRatio
;
// Ad overlay frame layout.
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
* implementation sets the aspect ratio of the content frame to that of the content, unless the
* content view is a {@link SphericalGLSurfaceView} in which case the frame's aspect ratio is
* cleared.
* 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 the specified value.
*
* @param contentAspectRatio The aspect ratio of the content.
* @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
(
float
contentAspectRatio
,
@Nullable
AspectRatioFrameLayout
contentFrame
,
@Nullable
View
contentView
)
{
@Nullable
AspectRatioFrameLayout
contentFrame
,
float
aspectRatio
)
{
if
(
contentFrame
!=
null
)
{
contentFrame
.
setAspectRatio
(
contentView
instanceof
SphericalGLSurfaceView
?
0
:
contentAspectRatio
);
contentFrame
.
setAspectRatio
(
aspectRatio
);
}
}
...
...
@@ -1366,7 +1365,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
int
drawableHeight
=
drawable
.
getIntrinsicHeight
();
if
(
drawableWidth
>
0
&&
drawableHeight
>
0
)
{
float
artworkAspectRatio
=
(
float
)
drawableWidth
/
drawableHeight
;
onContentAspectRatioChanged
(
artworkAspectRatio
,
contentFrame
,
artworkView
);
onContentAspectRatioChanged
(
contentFrame
,
artworkAspectRatio
);
artworkView
.
setImageDrawable
(
drawable
);
artworkView
.
setVisibility
(
VISIBLE
);
return
true
;
...
...
@@ -1542,7 +1541,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
applyTextureViewRotation
((
TextureView
)
surfaceView
,
textureViewRotation
);
}
onContentAspectRatioChanged
(
videoAspectRatio
,
contentFrame
,
surfaceView
);
onContentAspectRatioChanged
(
contentFrame
,
surfaceViewIgnoresVideoAspectRatio
?
0
:
videoAspectRatio
);
}
@Override
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java
View file @
bd654279
...
...
@@ -297,6 +297,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
@Nullable
private
final
AspectRatioFrameLayout
contentFrame
;
@Nullable
private
final
View
shutterView
;
@Nullable
private
final
View
surfaceView
;
private
final
boolean
surfaceViewIgnoresVideoAspectRatio
;
@Nullable
private
final
ImageView
artworkView
;
@Nullable
private
final
SubtitleView
subtitleView
;
@Nullable
private
final
View
bufferingView
;
...
...
@@ -341,6 +342,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
contentFrame
=
null
;
shutterView
=
null
;
surfaceView
=
null
;
surfaceViewIgnoresVideoAspectRatio
=
false
;
artworkView
=
null
;
subtitleView
=
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.
boolean
surfaceViewIgnoresVideoAspectRatio
=
false
;
if
(
contentFrame
!=
null
&&
surfaceType
!=
SURFACE_TYPE_NONE
)
{
ViewGroup
.
LayoutParams
params
=
new
ViewGroup
.
LayoutParams
(
...
...
@@ -432,6 +435,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
SphericalGLSurfaceView
sphericalGLSurfaceView
=
new
SphericalGLSurfaceView
(
context
);
sphericalGLSurfaceView
.
setSingleTapListener
(
componentListener
);
surfaceView
=
sphericalGLSurfaceView
;
surfaceViewIgnoresVideoAspectRatio
=
true
;
break
;
case
SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
surfaceView
=
new
VideoDecoderGLSurfaceView
(
context
);
...
...
@@ -445,6 +449,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
}
else
{
surfaceView
=
null
;
}
this
.
surfaceViewIgnoresVideoAspectRatio
=
surfaceViewIgnoresVideoAspectRatio
;
// Ad overlay frame layout.
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
* implementation sets the aspect ratio of the content frame to that of the content, unless the
* content view is a {@link SphericalGLSurfaceView} in which case the frame's aspect ratio is
* cleared.
* 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 the specified value.
*
* @param contentAspectRatio The aspect ratio of the content.
* @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
(
float
contentAspectRatio
,
@Nullable
AspectRatioFrameLayout
contentFrame
,
@Nullable
View
contentView
)
{
@Nullable
AspectRatioFrameLayout
contentFrame
,
float
aspectRatio
)
{
if
(
contentFrame
!=
null
)
{
contentFrame
.
setAspectRatio
(
contentView
instanceof
SphericalGLSurfaceView
?
0
:
contentAspectRatio
);
contentFrame
.
setAspectRatio
(
aspectRatio
);
}
}
...
...
@@ -1388,7 +1387,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
int
drawableHeight
=
drawable
.
getIntrinsicHeight
();
if
(
drawableWidth
>
0
&&
drawableHeight
>
0
)
{
float
artworkAspectRatio
=
(
float
)
drawableWidth
/
drawableHeight
;
onContentAspectRatioChanged
(
artworkAspectRatio
,
contentFrame
,
artworkView
);
onContentAspectRatioChanged
(
contentFrame
,
artworkAspectRatio
);
artworkView
.
setImageDrawable
(
drawable
);
artworkView
.
setVisibility
(
VISIBLE
);
return
true
;
...
...
@@ -1564,7 +1563,8 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
applyTextureViewRotation
((
TextureView
)
surfaceView
,
textureViewRotation
);
}
onContentAspectRatioChanged
(
videoAspectRatio
,
contentFrame
,
surfaceView
);
onContentAspectRatioChanged
(
contentFrame
,
surfaceViewIgnoresVideoAspectRatio
?
0
:
videoAspectRatio
);
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment