[Android] Prevent NPE with invalid file uri

Geoffrey Métais git at videolan.org
Thu Sep 13 17:41:15 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Sep 13 17:40:40 2018 +0200| [827366658e7e83d202be898752b9dafaaa7b1a2c] | committer: Geoffrey Métais

Prevent NPE with invalid file uri

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

 vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index c9bb91cc7..9b30791dd 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -1,6 +1,5 @@
 package org.videolan.vlc.media
 
-import android.arch.lifecycle.LiveData
 import android.arch.lifecycle.MutableLiveData
 import android.content.Intent
 import android.net.Uri
@@ -279,13 +278,13 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
             skipMedia()
         } else if (mw.type != MediaWrapper.TYPE_VIDEO || isVideoPlaying || player.hasRenderer
                 || mw.hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO)) {
-            val uri = Uri.parse(Uri.decode(FileUtils.getUri(mw.uri).toString()))
+            val uri = FileUtils.getUri(mw.uri)
             if (uri == null) {
                 skipMedia()
                 return
             }
             val start = getStartTime(mw)
-            val media = Media(VLCInstance.get(), uri)
+            val media = Media(VLCInstance.get(), Uri.parse(Uri.decode(uri.toString())))
             media.addOption(":start-time=$start")
             VLCOptions.setMediaOptions(media, ctx, flags or mw.flags)
             /* keeping only video during benchmark */



More information about the Android mailing list