[Android] Fix ANR when retrieving remote cover art

Robert Stone git at videolan.org
Fri Feb 17 12:27:06 UTC 2023


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Tue Feb 14 19:55:00 2023 -0800| [296d749602257e25c73ab5f56937d82665f3e201] | committer: Nicolas Pomepuy

Fix ANR when retrieving remote cover art

> https://code.videolan.org/videolan/vlc-android/commit/296d749602257e25c73ab5f56937d82665f3e201
---

 .../src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt          | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt
index 11385f76dc..9165ff1e5a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerAnimator.kt
@@ -223,8 +223,11 @@ internal class AudioPlayerAnimator : IAudioPlayerAnimator, LifecycleObserver {
             else {
                 val width = if (binding.contentLayout.width > 0) binding.contentLayout.width else audioPlayer.activity?.getScreenWidth() ?: return
                 val activity = audioPlayer.activity as? AudioPlayerContainerActivity ?: return
-                val bitmap = AudioUtil.readCoverBitmap(Uri.decode(mw.artworkMrl), width)
-                bitmap?.let { UiTools.blurView(binding.backgroundView, bitmap, 15F, UiTools.getColorFromAttribute(activity, R.attr.audio_player_background_tint)) } ?:  setDefaultBackground()
+                val cover = withContext(Dispatchers.IO) { AudioUtil.readCoverBitmap(Uri.decode(mw.artworkMrl), width) }
+                if (cover == null) setDefaultBackground()
+                else {
+                    UiTools.blurView(binding.backgroundView, cover, 15F, UiTools.getColorFromAttribute(activity, R.attr.audio_player_background_tint))
+                }
             }
         } else {
             currentCoverArt = null



More information about the Android mailing list