Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
533
Issue boards
Milestones
Wiki
Code
Merge requests
11
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
3ec4c42e
Commit
3ec4c42e
authored
3 years ago
by
Robert Stone
Committed by
Nicolas Pomepuy
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Attempt to load embedded artwork directly from media as a last resort
parent
a0a75daa
No related branches found
No related tags found
1 merge request
!1074
Pass bitmap to the media session. Provide URI in Android Auto mode.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/vlc-android/src/org/videolan/vlc/ArtworkProvider.kt
+24
-0
24 additions, 0 deletions
...ation/vlc-android/src/org/videolan/vlc/ArtworkProvider.kt
with
24 additions
and
0 deletions
application/vlc-android/src/org/videolan/vlc/ArtworkProvider.kt
+
24
−
0
View file @
3ec4c42e
...
...
@@ -33,9 +33,14 @@ import android.util.Log
import
android.util.LruCache
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.runBlocking
import
org.videolan.libvlc.FactoryManager
import
org.videolan.libvlc.interfaces.IMedia
import
org.videolan.libvlc.interfaces.IMediaFactory
import
org.videolan.medialibrary.MLServiceLocator
import
org.videolan.medialibrary.interfaces.Medialibrary
import
org.videolan.medialibrary.interfaces.media.MediaWrapper
import
org.videolan.medialibrary.media.MediaLibraryItem
import
org.videolan.resources.VLCInstance
import
org.videolan.resources.util.getFromMl
import
org.videolan.vlc.gui.helpers.AudioUtil
import
org.videolan.vlc.gui.helpers.getBitmapFromDrawable
...
...
@@ -210,6 +215,7 @@ class ArtworkProvider : ContentProvider() {
val
image
=
getOrPutImage
(
mw
?.
artworkMrl
?:
"${mediaId}}"
)
{
runBlocking
(
Dispatchers
.
IO
)
{
var
bitmap
=
if
(
mw
!=
null
)
ThumbnailsProvider
.
obtainBitmap
(
mw
,
width
)
else
null
if
(
bitmap
==
null
)
bitmap
=
readEmbeddedArtwork
(
mw
,
width
)
if
(
bitmap
!=
null
)
bitmap
=
padSquare
(
bitmap
)
if
(
bitmap
==
null
)
bitmap
=
ctx
.
getBitmapFromDrawable
(
R
.
drawable
.
ic_no_media
,
width
,
width
)
return
@runBlocking
encodeImage
(
bitmap
)
...
...
@@ -349,6 +355,24 @@ class ArtworkProvider : ContentProvider() {
return
bos
.
toByteArray
()
}
/**
* Attempt to directly load embedded artwork.
*/
private
fun
readEmbeddedArtwork
(
mw
:
MediaLibraryItem
?,
width
:
Int
):
Bitmap
?
{
if
(
mw
is
MediaWrapper
&&
mw
.
artworkMrl
==
null
&&
mw
.
uri
!=
null
)
{
var
media
:
IMedia
?
=
null
return
try
{
val
libVlc
=
VLCInstance
.
getInstance
(
ctx
)
val
mediaFactory
=
FactoryManager
.
getFactory
(
IMediaFactory
.
factoryId
)
as
IMediaFactory
media
=
mediaFactory
.
getFromUri
(
libVlc
,
mw
.
uri
).
apply
{
parse
()
}
AudioUtil
.
readCoverBitmap
(
Uri
.
decode
(
MLServiceLocator
.
getAbstractMediaWrapper
(
media
).
artworkMrl
),
width
)
}
finally
{
media
?.
release
()
}
}
return
null
}
/**
* Return a ParcelFileDescriptor from a Bitmap encoded in WEBP format. This function writes the
* compressed data stream directly to the file descriptor with no intermediate byte array.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment