Skip to content

Commit

Permalink
Merge branch 'fix-cat-insertremove' of https://github.com/jonmarkhall…
Browse files Browse the repository at this point in the history
…/just_audio into jonmarkhall-fix-cat-insertremove
  • Loading branch information
ryanheise committed Dec 15, 2024
2 parents f116d4a + 0e48668 commit d02bd5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 14 additions & 12 deletions just_audio/lib/just_audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2598,12 +2598,13 @@ class ConcatenatingAudioSource extends AudioSource {
if (_player != null) {
_player!._broadcastSequence();
await audioSource._setup(_player!);
await (await _player!._platform).concatenatingInsertAll(
ConcatenatingInsertAllRequest(
id: _id,
index: index,
children: [audioSource._toMessage()],
shuffleOrder: List.of(_shuffleOrder.indices)));
ConcatenatingInsertAllRequest request = ConcatenatingInsertAllRequest(
id: _id,
index: index,
children: [audioSource._toMessage()],
shuffleOrder: List.of(_shuffleOrder.indices)
);
await (await _player!._platform).concatenatingInsertAll(request);
}
}

Expand Down Expand Up @@ -2651,12 +2652,13 @@ class ConcatenatingAudioSource extends AudioSource {
_shuffleOrder.removeRange(index, index + 1);
if (_player != null) {
_player!._broadcastSequence();
await (await _player!._platform).concatenatingRemoveRange(
ConcatenatingRemoveRangeRequest(
id: _id,
startIndex: index,
endIndex: index + 1,
shuffleOrder: List.of(_shuffleOrder.indices)));
ConcatenatingRemoveRangeRequest request = ConcatenatingRemoveRangeRequest(
id: _id,
startIndex: index,
endIndex: index + 1,
shuffleOrder: List.of(_shuffleOrder.indices)
);
await (await _player!._platform).concatenatingRemoveRange(request);
}
}

Expand Down
4 changes: 4 additions & 0 deletions just_audio_background/lib/just_audio_background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ class _PlayerAudioHandler extends BaseAudioHandler
ConcatenatingInsertAllRequest request) async {
final cat = _source!.findCat(request.id)!;
cat.children.insertAll(request.index, request.children);
cat.shuffleOrder.clear();
cat.shuffleOrder.addAll(request.shuffleOrder);
_updateShuffleIndices();
_broadcastStateIfActive();
_updateQueue();
Expand All @@ -533,6 +535,8 @@ class _PlayerAudioHandler extends BaseAudioHandler
ConcatenatingRemoveRangeRequest request) async {
final cat = _source!.findCat(request.id)!;
cat.children.removeRange(request.startIndex, request.endIndex);
cat.shuffleOrder.clear();
cat.shuffleOrder.addAll(request.shuffleOrder);
_updateShuffleIndices();
_broadcastStateIfActive();
_updateQueue();
Expand Down

0 comments on commit d02bd5a

Please sign in to comment.