[Android] Fix wrong cover in PiP mode

Nicolas Pomepuy git at videolan.org
Mon Aug 1 12:01:41 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Aug  1 09:54:03 2022 +0200| [13bb68a6cbd4ab8146bd068df902de2516007197] | committer: Duncan McNamara

Fix wrong cover in PiP mode

> https://code.videolan.org/videolan/vlc-android/commit/13bb68a6cbd4ab8146bd068df902de2516007197
---

 application/vlc-android/src/org/videolan/vlc/PlaybackService.kt        | 2 +-
 .../vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt  | 1 +
 .../src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt         | 3 ++-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 30dad818c..af621cc2f 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -1195,7 +1195,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
         sendBroadcast(intent)
     }
 
-    private fun updateWidgetState() {
+    fun updateWidgetState() {
         val media = playlistManager.getCurrentMedia()
         val widgetIntents = arrayOf(Intent(VLCAppWidgetProvider.ACTION_WIDGET_UPDATE), Intent(MiniPlayerAppWidgetProvider.ACTION_WIDGET_UPDATE))
         lifecycleScope.launch(Dispatchers.Default) { widgetIntents.forEach { sendWidgetBroadcast(it) } }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index a4635ed7f..164754159 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -684,6 +684,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
                     val track = service?.playlistManager?.player?.mediaplayer?.currentVideoTrack
                             ?: return
                     val ar = Rational(track.width.coerceAtMost((track.height * 2.39f).toInt()), track.height)
+                    service?.updateWidgetState()
                     enterPictureInPictureMode(PictureInPictureParams.Builder().setAspectRatio(ar).build())
                 } catch (e: IllegalArgumentException) { // Fallback with default parameters
                     enterPictureInPictureMode()
diff --git a/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt b/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt
index 8129400b8..542596b94 100644
--- a/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt
@@ -284,7 +284,8 @@ class MiniPlayerAppWidgetProvider : AppWidgetProvider() {
             views.setImageViewBitmap(R.id.cover, cutBitmapCover(widgetType, previewBitmap!!, widgetCacheEntry))
         } else if (widgetCacheEntry.currentMedia?.artworkMrl != widgetCacheEntry.currentCover || widgetCacheEntry.currentCoverInvalidated) {
             widgetCacheEntry.currentCoverInvalidated = false
-            widgetCacheEntry.currentCover = widgetCacheEntry.currentMedia?.artworkMrl ?: settings.getString(KEY_CURRENT_AUDIO_RESUME_THUMB, null)
+            widgetCacheEntry.currentCover = if (service?.isVideoPlaying == false) widgetCacheEntry.currentMedia?.artworkMrl
+                    ?: settings.getString(KEY_CURRENT_AUDIO_RESUME_THUMB, null) else settings.getString(KEY_CURRENT_AUDIO_RESUME_THUMB, null)
             if (!widgetCacheEntry.currentCover.isNullOrEmpty()) {
                 log(appWidgetId, WidgetLogType.INFO, "Bugfix Refresh - Update cover: ${widgetCacheEntry.currentMedia?.artworkMrl} for ${widgetCacheEntry.widget.widgetId}")
                 runIO {



More information about the Android mailing list