From b258b5d76e6763411fdf419b58d81e4db431c7ce Mon Sep 17 00:00:00 2001 From: Ryan Heise Date: Sun, 4 Oct 2020 14:45:12 +1100 Subject: [PATCH] Fix bug in concatenating add/addAll. --- just_audio/lib/just_audio.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/just_audio/lib/just_audio.dart b/just_audio/lib/just_audio.dart index f1d426b..130f994 100644 --- a/just_audio/lib/just_audio.dart +++ b/just_audio/lib/just_audio.dart @@ -1317,14 +1317,13 @@ class ConcatenatingAudioSource extends AudioSource { /// (Untested) Appends an [AudioSource]. Future add(AudioSource audioSource) async { + final index = children.length; children.add(audioSource); _player._broadcastSequence(); if (_player != null) { await (await _player._platform).concatenatingInsertAll( ConcatenatingInsertAllRequest( - id: _id, - index: children.length, - children: [audioSource._toMessage()])); + id: _id, index: index, children: [audioSource._toMessage()])); } } @@ -1341,13 +1340,14 @@ class ConcatenatingAudioSource extends AudioSource { /// (Untested) Appends multiple [AudioSource]s. Future addAll(List children) async { + int index = this.children.length; this.children.addAll(children); _player._broadcastSequence(); if (_player != null) { await (await _player._platform).concatenatingInsertAll( ConcatenatingInsertAllRequest( id: _id, - index: this.children.length, + index: index, children: children.map((child) => child._toMessage()).toList())); } }