From 50402c904b40b73e2200fc08fe99832f1e7483fa Mon Sep 17 00:00:00 2001
From: Duncan McNamara <dcn.mcnamara@gmail.com>
Date: Thu, 3 Apr 2025 16:05:10 +0200
Subject: [PATCH] PlayIndex: fix play-as-audio

By getting a media from the medialibrary from the the currentmedia's uri
to ensure that we have the medialibrary metadata for the file, the new
media from the same uri won't have the flags previously set, including
MEDIA_FORCE_AUDIO which start the media as audio.

To fix this, the flags from the previous mediawrapper are applied to the
new one.

Fixed a regression introduced by ea39df7bb705507c41dd081732588335878142ba
---
 .../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt    | 1 +
 1 file changed, 1 insertion(+)

diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index ff77ea043a..048518d45d 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -484,6 +484,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
 
         val media = mediaList.getMedia(index) ?: return
         val mw = medialibrary.getMedia(media.uri) ?: media
+        mw.flags = media.flags
         val isInCustomPiP: Boolean = service.isInPiPMode.value ?: false
         if (mw.type == MediaWrapper.TYPE_VIDEO && !isAppStarted() && !isInCustomPiP) videoBackground = true
         val isVideoPlaying = mw.type == MediaWrapper.TYPE_VIDEO && player.isVideoPlaying()
-- 
GitLab