diff --git a/just_audio/darwin/Classes/AudioPlayer.m b/just_audio/darwin/Classes/AudioPlayer.m index a45b527..76479f5 100644 --- a/just_audio/darwin/Classes/AudioPlayer.m +++ b/just_audio/darwin/Classes/AudioPlayer.m @@ -1029,7 +1029,7 @@ // - when the shuffle order changes. (TODO) // - when the shuffle mode changes. 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; } else { _player.actionAtItemEnd = AVPlayerActionAtItemEndPause; // AVPlayerActionAtItemEndNone diff --git a/just_audio/lib/just_audio.dart b/just_audio/lib/just_audio.dart index 63f07e0..2d79b15 100644 --- a/just_audio/lib/just_audio.dart +++ b/just_audio/lib/just_audio.dart @@ -339,7 +339,7 @@ class AudioPlayer { shuffleModeEnabled == null) return null; if (loopMode == LoopMode.one) return currentIndex; final effectiveIndices = this.effectiveIndices; - if (effectiveIndices == null) return null; + if (effectiveIndices == null || effectiveIndices.isEmpty) return null; final effectiveIndicesInv = _effectiveIndicesInv; final invPos = effectiveIndicesInv[currentIndex]; var newInvPos = invPos + offset;