[Android] Fix NullPointerException on media location
Nicolas Pomepuy
git at videolan.org
Thu Feb 3 09:23:19 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Feb 1 13:27:36 2022 +0100| [6f3e345eddb7591bd092d7cb30b8c6f2945dcaf1] | committer: Nicolas Pomepuy
Fix NullPointerException on media location
> https://code.videolan.org/videolan/vlc-android/commit/6f3e345eddb7591bd092d7cb30b8c6f2945dcaf1
---
.../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 3b0c499fe..f6f962b5a 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -964,11 +964,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