mirror of
https://github.com/amigan/calls.git
synced 2024-11-21 20:39:47 -05:00
playqueue works!
This commit is contained in:
parent
74cc279069
commit
e4072458db
3 changed files with 14 additions and 12 deletions
|
@ -22,6 +22,7 @@ class Stillbox extends ChangeNotifier {
|
|||
Uri? baseUri = Uri.base;
|
||||
int queueLen = 0;
|
||||
final StreamController<SBCall> callStream = StreamController<SBCall>();
|
||||
final StreamController<int> callQStream = StreamController<int>();
|
||||
|
||||
set state(LiveState newState) {
|
||||
channel.sink.add(Live(state: newState, filter: currentFilter));
|
||||
|
@ -110,8 +111,8 @@ class Stillbox extends ChangeNotifier {
|
|||
}
|
||||
|
||||
void dispatchCall(SBCall call) {
|
||||
queueLen++;
|
||||
callStream.add(call);
|
||||
callQStream.add(1);
|
||||
}
|
||||
|
||||
void _handleData(dynamic event) {
|
||||
|
|
|
@ -14,12 +14,10 @@ class JustAudioDriver {
|
|||
initializer.audioInit();
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<justaudio.PlayerState> get playerStateStream {
|
||||
return player.playerStateStream;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> play(Call call) async {
|
||||
player.setAudioSource(CallBytesSource(call));
|
||||
await player.play();
|
||||
|
|
|
@ -27,22 +27,28 @@ class _MainRadioState extends State<MainRadio> {
|
|||
Timer? _lcdTimer;
|
||||
SBCall? _call;
|
||||
Completer _completer = Completer();
|
||||
int queueLen = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final sb = Provider.of<Stillbox>(context, listen: false);
|
||||
player.player.playerStateStream.listen((event) async {
|
||||
if (!event.playing &&
|
||||
event.processingState == ProcessingState.completed) {
|
||||
if (event.processingState == ProcessingState.completed &&
|
||||
!_completer.isCompleted) {
|
||||
_completer.complete();
|
||||
setState(() {
|
||||
_ledColor = Colors.black;
|
||||
});
|
||||
}
|
||||
});
|
||||
sb.callQStream.stream.listen((ctAdd) {
|
||||
setState(() {
|
||||
queueLen += ctAdd;
|
||||
});
|
||||
});
|
||||
|
||||
_callLoop(sb);
|
||||
// sb.callStream.stream.listen((call) async {
|
||||
}
|
||||
|
||||
void _callLoop(Stillbox sb) async {
|
||||
|
@ -50,13 +56,11 @@ class _MainRadioState extends State<MainRadio> {
|
|||
lcdOn();
|
||||
setState(() {
|
||||
_call = call;
|
||||
sb.queueLen--;
|
||||
queueLen--;
|
||||
});
|
||||
print("bef" + DateTime.now().toString());
|
||||
_completer = Completer();
|
||||
await player.play(call.call);
|
||||
player.play(call.call);
|
||||
await _completer.future;
|
||||
print("aft" + DateTime.now().toString());
|
||||
lcdOff();
|
||||
} //);
|
||||
}
|
||||
|
@ -100,8 +104,7 @@ class _MainRadioState extends State<MainRadio> {
|
|||
const ScannerLabel('Stillbox'),
|
||||
LED(_ledColor),
|
||||
]),
|
||||
LCD(_call, _lcdColor,
|
||||
Provider.of<Stillbox>(context, listen: false).queueLen),
|
||||
LCD(_call, _lcdColor, queueLen),
|
||||
const Keypad(),
|
||||
],
|
||||
)),
|
||||
|
|
Loading…
Reference in a new issue