[Android] Fix NullPointerException on media location
Nicolas Pomepuy
git at videolan.org
Thu Feb 3 09:26:10 UTC 2022
vlc-android | branch: 3.4.x | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Feb 1 13:27:36 2022 +0100| [4629dc6f37fe5e9e72ed56e3de2a9c5c5c580d01] | committer: Nicolas Pomepuy
Fix NullPointerException on media location
(cherry picked from commit 6f3e345eddb7591bd092d7cb30b8c6f2945dcaf1)
> https://code.videolan.org/videolan/vlc-android/commit/4629dc6f37fe5e9e72ed56e3de2a9c5c5c580d01
---
.../src/org/videolan/vlc/media/PlaylistManager.kt | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 2312d346e..5495371ee 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -962,11 +962,15 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
}
MediaPlayer.Event.EncounteredError -> {
- Log.w(TAG, "Invalid location ${getCurrentMedia()?.location}")
+ val location = try {
+ getCurrentMedia()?.location
+ } catch (e: NullPointerException) {
+ null
+ }
+ Log.w(TAG, "Invalid location $location")
- service.showToast(if (Uri.parse(getCurrentMedia()?.location).scheme == "missing") service.getString(R.string.missing_location) else service.getString(
- R.string.invalid_location,
- getCurrentMedia()?.location ?: ""), Toast.LENGTH_SHORT, true)
+ service.showToast(if (Uri.parse(location).scheme == "missing") service.getString(R.string.missing_location) else service.getString(R.string.invalid_location, location
+ ?: ""), Toast.LENGTH_SHORT, true)
if (currentIndex != nextIndex) next() else stop()
}
MediaPlayer.Event.TimeChanged -> {
More information about the Android
mailing list