[Android] Fix crash when playing a media container with missing medias

Nicolas Pomepuy git at videolan.org
Wed Dec 15 13:39:03 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Dec 15 14:26:42 2021 +0100| [c62c507b363118994cc7f98d7afaee2b0e9436e3] | committer: Nicolas Pomepuy

Fix crash when playing a media container with missing medias

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

 .../videolan/vlc/viewmodels/mobile/VideosViewModel.kt    | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt
index 9f10267aa..fe6f0a6ac 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt
@@ -87,8 +87,8 @@ class VideosViewModel(context: Context, type: VideoGroupingType, val folder: Fol
         val item = provider.pagedList.value?.get(position) ?: return at launch
         withContext(Dispatchers.IO) {
             when (item) {
-                is Folder -> item.getAll()
-                is VideoGroup -> item.getAll()
+                is Folder -> item.getAll(includeMissing = false)
+                is VideoGroup -> item.getAll(includeMissing = false)
                 is MediaWrapper -> listOf(item)
                 else -> null
             }
@@ -99,15 +99,15 @@ class VideosViewModel(context: Context, type: VideoGroupingType, val folder: Fol
         val item = provider.pagedList.value?.get(position) ?: return at launch
         withContext(Dispatchers.IO) {
             when (item) {
-                is Folder -> item.getAll()
-                is VideoGroup -> item.getAll()
+                is Folder -> item.getAll(includeMissing = false)
+                is VideoGroup -> item.getAll(includeMissing = false)
                 else -> null
             }
         }?.let { MediaUtils.appendMedia(context, it) }
     }
 
     internal fun playFoldersSelection(selection: List<Folder>) = viewModelScope.launch {
-        val list = selection.flatMap { it.getAll() }
+        val list = selection.flatMap { it.getAll(includeMissing = false) }
         MediaUtils.openList(context, list, 0)
     }
 
@@ -115,15 +115,15 @@ class VideosViewModel(context: Context, type: VideoGroupingType, val folder: Fol
         val item = provider.pagedList.value?.get(position) ?: return at launch
         withContext(Dispatchers.IO) {
             when (item) {
-                is Folder -> item.getAll()
-                is VideoGroup -> item.getAll()
+                is Folder -> item.getAll(includeMissing = false)
+                is VideoGroup -> item.getAll(includeMissing = false)
                 else -> null
             }
         }?.let { if (activity.isStarted()) activity.addToPlaylist(it) }
     }
 
     internal fun appendFoldersSelection(selection: List<Folder>) = viewModelScope.launch {
-        val list = selection.flatMap { it.getAll() }
+        val list = selection.flatMap { it.getAll(includeMissing = false) }
         MediaUtils.appendMedia(context, list)
     }
 



More information about the Android mailing list