Fix bug with play before load.
This commit is contained in:
parent
c19ac28584
commit
edd2fd5ff9
|
@ -114,19 +114,13 @@ class Html5AudioPlayer extends JustAudioPlayer {
|
||||||
|
|
||||||
List<int> get order {
|
List<int> get order {
|
||||||
final sequence = _audioSourcePlayer.sequence;
|
final sequence = _audioSourcePlayer.sequence;
|
||||||
List<int> order = List<int>(sequence.length);
|
return _shuffleModeEnabled
|
||||||
if (_shuffleModeEnabled) {
|
? _audioSourcePlayer.shuffleIndices
|
||||||
order = _audioSourcePlayer.shuffleIndices;
|
: List.generate(sequence.length, (i) => i);
|
||||||
} else {
|
|
||||||
for (var i = 0; i < order.length; i++) {
|
|
||||||
order[i] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return order;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> getInv(List<int> order) {
|
List<int> getInv(List<int> order) {
|
||||||
List<int> orderInv = List<int>(order.length);
|
final orderInv = List<int>.filled(order.length, 0);
|
||||||
for (var i = 0; i < order.length; i++) {
|
for (var i = 0; i < order.length; i++) {
|
||||||
orderInv[order[i]] = i;
|
orderInv[order[i]] = i;
|
||||||
}
|
}
|
||||||
|
@ -222,19 +216,21 @@ class Html5AudioPlayer extends JustAudioPlayer {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PlayResponse> play(PlayRequest request) async {
|
Future<PlayResponse> play(PlayRequest request) async {
|
||||||
|
if (_playing) return PlayResponse();
|
||||||
|
_playing = true;
|
||||||
await _play();
|
await _play();
|
||||||
return PlayResponse();
|
return PlayResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _play() async {
|
Future<void> _play() async {
|
||||||
_playing = true;
|
await _currentAudioSourcePlayer?.play();
|
||||||
await _currentAudioSourcePlayer.play();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PauseResponse> pause(PauseRequest request) async {
|
Future<PauseResponse> pause(PauseRequest request) async {
|
||||||
|
if (!_playing) return PauseResponse();
|
||||||
_playing = false;
|
_playing = false;
|
||||||
_currentAudioSourcePlayer.pause();
|
_currentAudioSourcePlayer?.pause();
|
||||||
return PauseResponse();
|
return PauseResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue