mirror of
https://github.com/bytedream/Yamete-Kudasai.git
synced 2025-06-27 08:40:33 +02:00
Proper update service, no sound on normal app start
This commit is contained in:
@ -38,25 +38,13 @@ void initBackground() {
|
||||
);
|
||||
|
||||
Map<UpdateAction, String>? data;
|
||||
int running = 0;
|
||||
|
||||
StreamSubscription<UpdateAction?>? sub = _portUpdate.stream.listen((event) async {
|
||||
data ??= (jsonDecode(generateEventData(await SharedPreferences.getInstance())) as Map<String, dynamic>)
|
||||
.map((key, value) => MapEntry(UpdateAction.values.elementAt(int.parse(key)), value as String));
|
||||
if (data!.containsKey(event!)) {
|
||||
final player = await _player.play(data![event]!);
|
||||
running++;
|
||||
FlutterBackgroundService().setNotificationInfo(
|
||||
title: 'Yamete Kudasai',
|
||||
content: 'Dispatching ${actions.values.elementAt(event.index).toLowerCase()} event'
|
||||
);
|
||||
await player.onPlayerCompletion.first;
|
||||
if (--running == 0) {
|
||||
FlutterBackgroundService().setNotificationInfo(
|
||||
title: 'Yamete Kudasai',
|
||||
content: 'Running'
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user