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
94fa4d99
authored
Aug 16, 2018
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'fix/vectorArtWork' of
https://github.com/mitrejcevski/ExoPlayer
into dev-v2
parents
52b6b3b8
5635ca27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 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 @
94fa4d99
...
...
@@ -26,8 +26,11 @@ import android.graphics.BitmapFactory;
import
android.graphics.Matrix
;
import
android.graphics.RectF
;
import
android.support.annotation.IntDef
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.v4.content.ContextCompat
;
import
android.util.AttributeSet
;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
...
...
@@ -262,7 +265,7 @@ public class PlayerView extends FrameLayout {
private
Player
player
;
private
boolean
useController
;
private
boolean
useArtwork
;
private
Bitmap
defaultArtwork
;
private
Drawable
defaultArtwork
;
private
@ShowBuffering
int
showBuffering
;
private
boolean
keepContentOnPlayerReset
;
private
@Nullable
ErrorMessageProvider
<?
super
ExoPlaybackException
>
errorMessageProvider
;
...
...
@@ -394,7 +397,7 @@ public class PlayerView extends FrameLayout {
artworkView
=
findViewById
(
R
.
id
.
exo_artwork
);
this
.
useArtwork
=
useArtwork
&&
artworkView
!=
null
;
if
(
defaultArtworkId
!=
0
)
{
defaultArtwork
=
BitmapFactory
.
decodeResource
(
context
.
getResources
(),
defaultArtworkId
);
defaultArtwork
=
ContextCompat
.
getDrawable
(
getContext
(),
defaultArtworkId
);
}
// Subtitle view.
...
...
@@ -583,7 +586,7 @@ public class PlayerView extends FrameLayout {
}
/** Returns the default artwork to display. */
public
Bitmap
getDefaultArtwork
()
{
public
Drawable
getDefaultArtwork
()
{
return
defaultArtwork
;
}
...
...
@@ -592,8 +595,20 @@ public class PlayerView extends FrameLayout {
* present in the media.
*
* @param defaultArtwork the default artwork to display.
* @deprecated use (@link {@link #setDefaultArtwork(Drawable)} instead.
*/
@Deprecated
public
void
setDefaultArtwork
(
Bitmap
defaultArtwork
)
{
setDefaultArtwork
(
new
BitmapDrawable
(
getResources
(),
defaultArtwork
));
}
/**
* Sets the default artwork to display if {@code useArtwork} is {@code true} and no artwork is
* present in the media.
*
* @param defaultArtwork the default artwork to display
*/
public
void
setDefaultArtwork
(
Drawable
defaultArtwork
)
{
if
(
this
.
defaultArtwork
!=
defaultArtwork
)
{
this
.
defaultArtwork
=
defaultArtwork
;
updateForCurrentTrackSelections
(
/* isNewPlayer= */
false
);
...
...
@@ -1118,7 +1133,7 @@ public class PlayerView extends FrameLayout {
}
}
}
if
(
set
ArtworkFromBitmap
(
defaultArtwork
))
{
if
(
set
DrawableArtwork
(
defaultArtwork
))
{
return
;
}
}
...
...
@@ -1132,26 +1147,20 @@ public class PlayerView extends FrameLayout {
if
(
metadataEntry
instanceof
ApicFrame
)
{
byte
[]
bitmapData
=
((
ApicFrame
)
metadataEntry
).
pictureData
;
Bitmap
bitmap
=
BitmapFactory
.
decodeByteArray
(
bitmapData
,
0
,
bitmapData
.
length
);
return
set
ArtworkFromBitmap
(
bitmap
);
return
set
DrawableArtwork
(
new
BitmapDrawable
(
getResources
(),
bitmap
)
);
}
}
return
false
;
}
private
boolean
setArtworkFromBitmap
(
Bitmap
bitmap
)
{
if
(
bitmap
!=
null
)
{
int
bitmapWidth
=
bitmap
.
getWidth
();
int
bitmapHeight
=
bitmap
.
getHeight
();
if
(
bitmapWidth
>
0
&&
bitmapHeight
>
0
)
{
if
(
contentFrame
!=
null
)
{
contentFrame
.
setAspectRatio
((
float
)
bitmapWidth
/
bitmapHeight
);
}
artworkView
.
setImageBitmap
(
bitmap
);
artworkView
.
setVisibility
(
VISIBLE
);
return
true
;
private
boolean
setDrawableArtwork
(
Drawable
drawable
)
{
if
(
drawable
!=
null
)
{
artworkView
.
setImageDrawable
(
drawable
);
if
(
contentFrame
!=
null
)
{
contentFrame
.
setAspectRatio
(
0
);
}
}
return
fals
e
;
return
tru
e
;
}
private
void
hideArtwork
()
{
...
...
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