[Android] Allow playing multiple media with drag and drop

Nicolas Pomepuy git at videolan.org
Mon Oct 7 09:28:52 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Sep 30 14:02:11 2024 +0200| [9944072d03dd779b60777be35b2ed41ced1b0f4e] | committer: Nicolas Pomepuy

Allow playing multiple media with drag and drop

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

 .../src/org/videolan/vlc/gui/helpers/UiTools.kt       | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
index f07c3d83f5..1315f28629 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
@@ -41,7 +41,6 @@ import android.os.Handler
 import android.os.Looper
 import android.renderscript.*
 import android.text.TextUtils
-import android.util.Log
 import android.view.*
 import android.view.animation.*
 import android.view.inputmethod.InputMethodManager
@@ -85,7 +84,6 @@ import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.resources.*
 import org.videolan.resources.util.launchForeground
 import org.videolan.tools.*
-import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.BuildConfig.VLC_VERSION_NAME
 import org.videolan.vlc.MediaParsingService
 import org.videolan.vlc.R
@@ -779,22 +777,19 @@ object UiTools {
                 DragEvent.ACTION_DROP -> {
                     val clipData = event.clipData ?: return at OnDragListener false
                     val itemsCount = clipData.itemCount
+                    val uriList = mutableListOf<MediaWrapper>()
                     for (i in 0 until itemsCount) {
                         val permissions = activity.requestDragAndDropPermissions(event)
                         if (permissions != null) {
                             val item = clipData.getItemAt(i)
-                            if (item.uri != null)
-                                MediaUtils.openUri(activity, item.uri)
-                            else if (item.text != null) {
-                                val uri = item.text.toString().toUri()
-                                val media = MLServiceLocator.getAbstractMediaWrapper(uri)
-                                if ("file" != uri.scheme)
-                                    media.type = MediaWrapper.TYPE_STREAM
-                                MediaUtils.openMedia(activity, media)
-                            }
-                            return at OnDragListener true
+                            val uri = item.uri ?: item.text.toString().toUri()
+                            val media = MLServiceLocator.getAbstractMediaWrapper(uri)
+                            if ("file" != uri.scheme)
+                                media.type = MediaWrapper.TYPE_STREAM
+                            uriList.add(media)
                         }
                     }
+                    MediaUtils.openList(activity, uriList, 0)
                     false
                 }
                 else -> false



More information about the Android mailing list