[Android] PlaylistManager: Prevent IndexOutOfBoundsException

Geoffrey Métais git at videolan.org
Tue Jun 25 15:20:24 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jun 25 13:46:36 2019 +0200| [07d4002053a5846aec3384dd44ca94827a59e043] | committer: Geoffrey Métais

PlaylistManager: Prevent IndexOutOfBoundsException

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

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

diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 75e1389bf..872054015 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -25,6 +25,7 @@ import org.videolan.vlc.VLCApplication
 import org.videolan.vlc.gui.video.VideoPlayerActivity
 import org.videolan.vlc.util.*
 import java.util.*
+import kotlin.math.max
 
 private const val TAG = "VLC/PlaylistManager"
 private const val PREVIOUS_LIMIT_DELAY = 5000L
@@ -159,7 +160,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
             // load playlist
             shuffling = settings.getBoolean(if (audio) "audio_shuffling" else "media_shuffling", false)
             repeating = settings.getInt(if (audio) "audio_repeating" else "media_repeating", REPEAT_NONE)
-            val position = settings.getInt(if (audio) "position_in_audio_list" else "position_in_media_list", 0)
+            val position = max(0, settings.getInt(if (audio) "position_in_audio_list" else "position_in_media_list", 0))
             savedTime = settings.getLong(if (audio) "position_in_song" else "position_in_media", -1)
             if (!audio && position < playList.size && settings.getBoolean(VIDEO_PAUSED, false)) {
                 playList[position].addFlags(MediaWrapper.MEDIA_PAUSED)



More information about the Android mailing list