After a certain time, I want to turn off audio_service in the background with the android_alarm_manager plugin After a certain time, I want to turn off audio_service in the background with the android_alarm_manager plugin dart dart

After a certain time, I want to turn off audio_service in the background with the android_alarm_manager plugin


You have the right idea, although you have to wait until it is actually connected using "await":

await AudioService.connect();AudioService.stop();

For this to work, you will also need to upgrade to release 0.9.0 or later which mentions in the CHANGELOG:

  • Allow connections from background contexts (e.g. android_alarm_manager).