[Android] Parse ContentProvider Uri when starting to play from external app

Nicolas Pomepuy git at videolan.org
Thu Jul 2 11:51:03 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jul  2 10:21:43 2020 +0200| [5a60061fdc14623a1e2b1796ecd7ee3e97bcec9b] | committer: Nicolas Pomepuy

Parse ContentProvider Uri when starting to play from external app

It allows the app to save the playback item as a proper media instead
of an external one.
The history now display the proper media name, thumb etc

Fixes #1381

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

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt            | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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 69f1bdd62..f47ef0428 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
@@ -2355,7 +2355,10 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
                 wasPaused = true
             if (wasPaused && BuildConfig.DEBUG)
                 Log.d(TAG, "Video was previously paused, resuming in paused mode")
-            if (intent.data != null) videoUri = intent.data
+            intent.data?.let {
+               val translatedPath = FileUtils.getPathFromURI(it)
+                videoUri = if (!translatedPath.isEmpty()) Uri.parse(translatedPath) else it
+            }
             if (extras != null) {
                 if (intent.hasExtra(PLAY_EXTRA_ITEM_LOCATION)) {
                     videoUri = extras.getParcelable(PLAY_EXTRA_ITEM_LOCATION)



More information about the Android mailing list