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
1f176253
authored
Jul 24, 2018
by
Jovche Mitrejchevski
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Support vector drawables to be used as default artwork
parent
61b838f4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 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 @
1f176253
...
@@ -22,10 +22,15 @@ import android.content.res.Resources;
...
@@ -22,10 +22,15 @@ import android.content.res.Resources;
import
android.content.res.TypedArray
;
import
android.content.res.TypedArray
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Matrix
;
import
android.graphics.Matrix
;
import
android.graphics.RectF
;
import
android.graphics.RectF
;
import
android.graphics.drawable.Drawable
;
import
android.os.Build
;
import
android.support.annotation.NonNull
;
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.graphics.drawable.DrawableCompat
;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
import
android.view.KeyEvent
;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
...
@@ -368,7 +373,7 @@ public class PlayerView extends FrameLayout {
...
@@ -368,7 +373,7 @@ public class PlayerView extends FrameLayout {
artworkView
=
findViewById
(
R
.
id
.
exo_artwork
);
artworkView
=
findViewById
(
R
.
id
.
exo_artwork
);
this
.
useArtwork
=
useArtwork
&&
artworkView
!=
null
;
this
.
useArtwork
=
useArtwork
&&
artworkView
!=
null
;
if
(
defaultArtworkId
!=
0
)
{
if
(
defaultArtworkId
!=
0
)
{
defaultArtwork
=
BitmapFactory
.
decodeResource
(
context
.
getResources
(),
defaultArtworkId
);
defaultArtwork
=
loadFromResource
(
defaultArtworkId
);
}
}
// Subtitle view.
// Subtitle view.
...
@@ -416,6 +421,21 @@ public class PlayerView extends FrameLayout {
...
@@ -416,6 +421,21 @@ public class PlayerView extends FrameLayout {
hideController
();
hideController
();
}
}
private
Bitmap
loadFromResource
(
int
defaultArtworkId
)
{
Drawable
drawable
=
ContextCompat
.
getDrawable
(
getContext
(),
defaultArtworkId
);
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
drawable
=
(
DrawableCompat
.
wrap
(
drawable
)).
mutate
();
}
Bitmap
bitmap
=
Bitmap
.
createBitmap
(
drawable
.
getIntrinsicWidth
(),
drawable
.
getIntrinsicHeight
(),
Bitmap
.
Config
.
ARGB_8888
);
Canvas
canvas
=
new
Canvas
(
bitmap
);
drawable
.
setBounds
(
0
,
0
,
canvas
.
getWidth
(),
canvas
.
getHeight
());
drawable
.
draw
(
canvas
);
return
bitmap
;
}
/**
/**
* Switches the view targeted by a given {@link Player}.
* Switches the view targeted by a given {@link Player}.
*
*
...
...
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