[Android] Get a usable Uri from subtitle files Uri using a ContentProvider

Nicolas Pomepuy git at videolan.org
Tue Nov 2 12:37:19 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Oct 22 08:32:52 2021 +0200| [e4bfcbc88eaf024d6aef9c86b376f4bd3306fcd0] | committer: Nicolas Pomepuy

Get a usable Uri from subtitle files Uri using a ContentProvider

Fixes #2192

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

 .../vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 4 +++-
 1 file changed, 3 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 05763ed3a..a9b7635e4 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
@@ -104,6 +104,7 @@ import org.videolan.vlc.repository.ExternalSubRepository
 import org.videolan.vlc.repository.SlaveRepository
 import org.videolan.vlc.util.*
 import org.videolan.vlc.util.FileUtils
+import org.videolan.vlc.util.FileUtils.getUri
 import org.videolan.vlc.viewmodels.BookmarkModel
 import org.videolan.vlc.viewmodels.PlaylistModel
 import java.lang.Runnable
@@ -848,7 +849,8 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
         if (data == null) return
 
         if (data.hasExtra(EXTRA_MRL)) {
-            service?.addSubtitleTrack(data.getStringExtra(EXTRA_MRL)!!.toUri(), false)
+            val subtitleUri = data.getStringExtra(EXTRA_MRL)!!.toUri()
+            service?.addSubtitleTrack(getUri(subtitleUri) ?: subtitleUri, false)
             service?.currentMediaWrapper?.let {
                 SlaveRepository.getInstance(this).saveSlave(it.location, IMedia.Slave.Type.Subtitle, 2, data.getStringExtra(EXTRA_MRL)!!)
             }



More information about the Android mailing list