Fix exception with empty playlist

This commit is contained in:
Ryan Heise 2021-01-15 23:32:59 +11:00
parent a74834af37
commit 47fde5cc74
2 changed files with 2 additions and 2 deletions

View File

@ -1029,7 +1029,7 @@
// - when the shuffle order changes. (TODO) // - when the shuffle order changes. (TODO)
// - when the shuffle mode changes. // - when the shuffle mode changes.
if (!_player) return; if (!_player) return;
if (_audioSource && (_loopMode != loopOff || [_orderInv[_index] intValue] + 1 < [_order count])) { if (_audioSource && (_loopMode != loopOff || ([_order count] > 0 && [_orderInv[_index] intValue] + 1 < [_order count]))) {
_player.actionAtItemEnd = AVPlayerActionAtItemEndAdvance; _player.actionAtItemEnd = AVPlayerActionAtItemEndAdvance;
} else { } else {
_player.actionAtItemEnd = AVPlayerActionAtItemEndPause; // AVPlayerActionAtItemEndNone _player.actionAtItemEnd = AVPlayerActionAtItemEndPause; // AVPlayerActionAtItemEndNone

View File

@ -339,7 +339,7 @@ class AudioPlayer {
shuffleModeEnabled == null) return null; shuffleModeEnabled == null) return null;
if (loopMode == LoopMode.one) return currentIndex; if (loopMode == LoopMode.one) return currentIndex;
final effectiveIndices = this.effectiveIndices; final effectiveIndices = this.effectiveIndices;
if (effectiveIndices == null) return null; if (effectiveIndices == null || effectiveIndices.isEmpty) return null;
final effectiveIndicesInv = _effectiveIndicesInv; final effectiveIndicesInv = _effectiveIndicesInv;
final invPos = effectiveIndicesInv[currentIndex]; final invPos = effectiveIndicesInv[currentIndex];
var newInvPos = invPos + offset; var newInvPos = invPos + offset;