Commit 07d40020 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

PlaylistManager: Prevent IndexOutOfBoundsException

parent 79b21d9e
...@@ -25,6 +25,7 @@ import org.videolan.vlc.VLCApplication ...@@ -25,6 +25,7 @@ import org.videolan.vlc.VLCApplication
import org.videolan.vlc.gui.video.VideoPlayerActivity import org.videolan.vlc.gui.video.VideoPlayerActivity
import org.videolan.vlc.util.* import org.videolan.vlc.util.*
import java.util.* import java.util.*
import kotlin.math.max
private const val TAG = "VLC/PlaylistManager" private const val TAG = "VLC/PlaylistManager"
private const val PREVIOUS_LIMIT_DELAY = 5000L private const val PREVIOUS_LIMIT_DELAY = 5000L
...@@ -159,7 +160,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList ...@@ -159,7 +160,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
// load playlist // load playlist
shuffling = settings.getBoolean(if (audio) "audio_shuffling" else "media_shuffling", false) shuffling = settings.getBoolean(if (audio) "audio_shuffling" else "media_shuffling", false)
repeating = settings.getInt(if (audio) "audio_repeating" else "media_repeating", REPEAT_NONE) 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) savedTime = settings.getLong(if (audio) "position_in_song" else "position_in_media", -1)
if (!audio && position < playList.size && settings.getBoolean(VIDEO_PAUSED, false)) { if (!audio && position < playList.size && settings.getBoolean(VIDEO_PAUSED, false)) {
playList[position].addFlags(MediaWrapper.MEDIA_PAUSED) playList[position].addFlags(MediaWrapper.MEDIA_PAUSED)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment