Skip to content

Commit

Permalink
Fix shuffleOrder in just_audio_background for ConcatenatingMoveRequest.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed Dec 15, 2024
1 parent d02bd5a commit f75582c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
26 changes: 12 additions & 14 deletions just_audio/lib/just_audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2598,13 +2598,12 @@ class ConcatenatingAudioSource extends AudioSource {
if (_player != null) {
_player!._broadcastSequence();
await audioSource._setup(_player!);
ConcatenatingInsertAllRequest request = ConcatenatingInsertAllRequest(
id: _id,
index: index,
children: [audioSource._toMessage()],
shuffleOrder: List.of(_shuffleOrder.indices)
);
await (await _player!._platform).concatenatingInsertAll(request);
await (await _player!._platform).concatenatingInsertAll(
ConcatenatingInsertAllRequest(
id: _id,
index: index,
children: [audioSource._toMessage()],
shuffleOrder: List.of(_shuffleOrder.indices)));
}
}

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

Expand Down
4 changes: 4 additions & 0 deletions just_audio_background/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.1-beta.14

* Fix shuffleOrder when mutating ConcatenatingAudioSource (@jonmarkhall).

## 0.0.1-beta.13

* Support rxdart 0.28.x.
Expand Down
10 changes: 6 additions & 4 deletions just_audio_background/lib/just_audio_background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +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);
cat.shuffleOrder
.replaceRange(0, cat.shuffleOrder.length, request.shuffleOrder);
_updateShuffleIndices();
_broadcastStateIfActive();
_updateQueue();
Expand All @@ -535,8 +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);
cat.shuffleOrder
.replaceRange(0, cat.shuffleOrder.length, request.shuffleOrder);
_updateShuffleIndices();
_broadcastStateIfActive();
_updateQueue();
Expand All @@ -548,6 +548,8 @@ class _PlayerAudioHandler extends BaseAudioHandler
final cat = _source!.findCat(request.id)!;
cat.children
.insert(request.newIndex, cat.children.removeAt(request.currentIndex));
cat.shuffleOrder
.replaceRange(0, cat.shuffleOrder.length, request.shuffleOrder);
_updateShuffleIndices();
_broadcastStateIfActive();
_updateQueue();
Expand Down
2 changes: 1 addition & 1 deletion just_audio_background/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: just_audio_background
description: An add-on for just_audio that supports background playback and media notifications.
homepage: https://github.com/ryanheise/just_audio/tree/master/just_audio_background
version: 0.0.1-beta.13
version: 0.0.1-beta.14
topics:
- audio
- sound
Expand Down

0 comments on commit f75582c

Please sign in to comment.