queue kind of works

This commit is contained in:
Daniel 2024-08-18 08:41:29 -04:00
parent d52c8310a3
commit 74cc279069

View file

@ -26,6 +26,7 @@ class _MainRadioState extends State<MainRadio> {
Color _ledColor = Colors.black; Color _ledColor = Colors.black;
Timer? _lcdTimer; Timer? _lcdTimer;
SBCall? _call; SBCall? _call;
Completer _completer = Completer();
@override @override
void initState() { void initState() {
@ -34,6 +35,7 @@ class _MainRadioState extends State<MainRadio> {
player.player.playerStateStream.listen((event) async { player.player.playerStateStream.listen((event) async {
if (!event.playing && if (!event.playing &&
event.processingState == ProcessingState.completed) { event.processingState == ProcessingState.completed) {
_completer.complete();
setState(() { setState(() {
_ledColor = Colors.black; _ledColor = Colors.black;
}); });
@ -50,9 +52,11 @@ class _MainRadioState extends State<MainRadio> {
_call = call; _call = call;
sb.queueLen--; sb.queueLen--;
}); });
print("bef"); print("bef" + DateTime.now().toString());
_completer = Completer();
await player.play(call.call); await player.play(call.call);
print("aft"); await _completer.future;
print("aft" + DateTime.now().toString());
lcdOff(); lcdOff();
} //); } //);
} }