[Android] Playlistmanager: Nullity check on mediaplayer evt

Geoffrey Métais git at videolan.org
Mon Jan 28 15:01:22 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 28 14:51:06 2019 +0100| [875e96f86b8fa794497b4429ef278cfed0f1368f] | committer: Geoffrey Métais

Playlistmanager: Nullity check on mediaplayer evt

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

 vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 9 ++++++---
 1 file changed, 6 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 4979961b5..cafe76396 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -742,9 +742,12 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
                 MediaPlayer.Event.Playing -> {
                     medialibrary.pauseBackgroundOperations()
                     val mw = withContext(Dispatchers.IO) {
-                        val current = getCurrentMedia()
-                        medialibrary.findMedia(current).apply { if (type == -1) type = current?.type ?: -1 }
-                    }
+                        getCurrentMedia()?.let {
+                            medialibrary.findMedia(it).apply {
+                                if (type == -1) type = it.type
+                            }
+                        }
+                    } ?: return
                     if (newMedia) {
                         loadMediaMeta(mw)
                         saveMediaList()



More information about the Android mailing list