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
3bfe103b
authored
Dec 14, 2018
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #5245 from natario1:videosize-override
PiperOrigin-RevId: 225187852
parents
7d21154b
c8198565
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
20 deletions
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
View file @
3bfe103b
...
@@ -29,7 +29,6 @@ import android.graphics.drawable.BitmapDrawable;
...
@@ -29,7 +29,6 @@ import android.graphics.drawable.BitmapDrawable;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.os.Looper
;
import
android.os.Looper
;
import
android.support.annotation.IntDef
;
import
android.support.annotation.IntDef
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
...
@@ -271,13 +270,13 @@ public class PlayerView extends FrameLayout {
...
@@ -271,13 +270,13 @@ public class PlayerView extends FrameLayout {
private
static
final
int
SURFACE_TYPE_MONO360_VIEW
=
3
;
private
static
final
int
SURFACE_TYPE_MONO360_VIEW
=
3
;
// LINT.ThenChange(../../../../../../res/values/attrs.xml)
// LINT.ThenChange(../../../../../../res/values/attrs.xml)
private
final
AspectRatioFrameLayout
contentFrame
;
@Nullable
private
final
AspectRatioFrameLayout
contentFrame
;
private
final
View
shutterView
;
private
final
View
shutterView
;
private
final
View
surfaceView
;
@Nullable
private
final
View
surfaceView
;
private
final
ImageView
artworkView
;
private
final
ImageView
artworkView
;
private
final
SubtitleView
subtitleView
;
private
final
SubtitleView
subtitleView
;
private
final
@Nullable
View
bufferingView
;
@Nullable
private
final
View
bufferingView
;
private
final
@Nullable
TextView
errorMessageView
;
@Nullable
private
final
TextView
errorMessageView
;
private
final
PlayerControlView
controller
;
private
final
PlayerControlView
controller
;
private
final
ComponentListener
componentListener
;
private
final
ComponentListener
componentListener
;
private
final
FrameLayout
overlayFrameLayout
;
private
final
FrameLayout
overlayFrameLayout
;
...
@@ -285,11 +284,11 @@ public class PlayerView extends FrameLayout {
...
@@ -285,11 +284,11 @@ public class PlayerView extends FrameLayout {
private
Player
player
;
private
Player
player
;
private
boolean
useController
;
private
boolean
useController
;
private
boolean
useArtwork
;
private
boolean
useArtwork
;
private
@Nullabl
e
Drawable
defaultArtwork
;
@Nullable
privat
e
Drawable
defaultArtwork
;
private
@ShowBuffering
int
showBuffering
;
private
@ShowBuffering
int
showBuffering
;
private
boolean
keepContentOnPlayerReset
;
private
boolean
keepContentOnPlayerReset
;
private
@Nullabl
e
ErrorMessageProvider
<?
super
ExoPlaybackException
>
errorMessageProvider
;
@Nullable
privat
e
ErrorMessageProvider
<?
super
ExoPlaybackException
>
errorMessageProvider
;
private
@Nullabl
e
CharSequence
customErrorMessage
;
@Nullable
privat
e
CharSequence
customErrorMessage
;
private
int
controllerShowTimeoutMs
;
private
int
controllerShowTimeoutMs
;
private
boolean
controllerAutoShow
;
private
boolean
controllerAutoShow
;
private
boolean
controllerHideDuringAds
;
private
boolean
controllerHideDuringAds
;
...
@@ -474,9 +473,7 @@ public class PlayerView extends FrameLayout {
...
@@ -474,9 +473,7 @@ public class PlayerView extends FrameLayout {
* @param newPlayerView The new view to attach to the player.
* @param newPlayerView The new view to attach to the player.
*/
*/
public
static
void
switchTargetView
(
public
static
void
switchTargetView
(
@NonNull
Player
player
,
Player
player
,
@Nullable
PlayerView
oldPlayerView
,
@Nullable
PlayerView
newPlayerView
)
{
@Nullable
PlayerView
oldPlayerView
,
@Nullable
PlayerView
newPlayerView
)
{
if
(
oldPlayerView
==
newPlayerView
)
{
if
(
oldPlayerView
==
newPlayerView
)
{
return
;
return
;
}
}
...
@@ -1080,6 +1077,26 @@ public class PlayerView extends FrameLayout {
...
@@ -1080,6 +1077,26 @@ public class PlayerView extends FrameLayout {
}
}
}
}
/**
* 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 SphericalSurfaceView} 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 contentView The view that holds the content being displayed, or {@code null}.
*/
protected
void
onContentAspectRatioChanged
(
float
contentAspectRatio
,
@Nullable
AspectRatioFrameLayout
contentFrame
,
@Nullable
View
contentView
)
{
if
(
contentFrame
!=
null
)
{
contentFrame
.
setAspectRatio
(
contentView
instanceof
SphericalSurfaceView
?
0
:
contentAspectRatio
);
}
}
private
boolean
toggleControllerVisibility
()
{
private
boolean
toggleControllerVisibility
()
{
if
(!
useController
||
player
==
null
)
{
if
(!
useController
||
player
==
null
)
{
return
false
;
return
false
;
...
@@ -1193,9 +1210,8 @@ public class PlayerView extends FrameLayout {
...
@@ -1193,9 +1210,8 @@ public class PlayerView extends FrameLayout {
int
drawableWidth
=
drawable
.
getIntrinsicWidth
();
int
drawableWidth
=
drawable
.
getIntrinsicWidth
();
int
drawableHeight
=
drawable
.
getIntrinsicHeight
();
int
drawableHeight
=
drawable
.
getIntrinsicHeight
();
if
(
drawableWidth
>
0
&&
drawableHeight
>
0
)
{
if
(
drawableWidth
>
0
&&
drawableHeight
>
0
)
{
if
(
contentFrame
!=
null
)
{
float
artworkAspectRatio
=
(
float
)
drawableWidth
/
drawableHeight
;
contentFrame
.
setAspectRatio
((
float
)
drawableWidth
/
drawableHeight
);
onContentAspectRatioChanged
(
artworkAspectRatio
,
contentFrame
,
artworkView
);
}
artworkView
.
setImageDrawable
(
drawable
);
artworkView
.
setImageDrawable
(
drawable
);
artworkView
.
setVisibility
(
VISIBLE
);
artworkView
.
setVisibility
(
VISIBLE
);
return
true
;
return
true
;
...
@@ -1328,9 +1344,6 @@ public class PlayerView extends FrameLayout {
...
@@ -1328,9 +1344,6 @@ public class PlayerView extends FrameLayout {
@Override
@Override
public
void
onVideoSizeChanged
(
public
void
onVideoSizeChanged
(
int
width
,
int
height
,
int
unappliedRotationDegrees
,
float
pixelWidthHeightRatio
)
{
int
width
,
int
height
,
int
unappliedRotationDegrees
,
float
pixelWidthHeightRatio
)
{
if
(
contentFrame
==
null
)
{
return
;
}
float
videoAspectRatio
=
float
videoAspectRatio
=
(
height
==
0
||
width
==
0
)
?
1
:
(
width
*
pixelWidthHeightRatio
)
/
height
;
(
height
==
0
||
width
==
0
)
?
1
:
(
width
*
pixelWidthHeightRatio
)
/
height
;
...
@@ -1351,11 +1364,9 @@ public class PlayerView extends FrameLayout {
...
@@ -1351,11 +1364,9 @@ public class PlayerView extends FrameLayout {
surfaceView
.
addOnLayoutChangeListener
(
this
);
surfaceView
.
addOnLayoutChangeListener
(
this
);
}
}
applyTextureViewRotation
((
TextureView
)
surfaceView
,
textureViewRotation
);
applyTextureViewRotation
((
TextureView
)
surfaceView
,
textureViewRotation
);
}
else
if
(
surfaceView
instanceof
SphericalSurfaceView
)
{
videoAspectRatio
=
0
;
}
}
contentFrame
.
setAspectRatio
(
videoAspectRatio
);
onContentAspectRatioChanged
(
videoAspectRatio
,
contentFrame
,
surfaceView
);
}
}
@Override
@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