Sithira / FlutterRadioPlayer

Flutter Radio Player, A Plugin to handle streaming audio without a hassle
MIT License
139 stars 64 forks source link

Fixes foreground service not stopped when app gets destroyed #40

Closed JanStorm closed 2 years ago

JanStorm commented 3 years ago

This issue is android-only. Using flutter plugin flutter_plugin_android_lifecycle we can register a listener for app destroy event. When app gets destroyed, we want the foregroundservice to stop. Otherwise wenn we reopen the app, the plugin cannot connect to the running service and gets buggy.

We have to do this logic in platform-specific code, since _channel.invokeMethod wont work on flutter side when trying to call stop via WidgetsBindingObserver. See issue https://github.com/flutter/flutter/issues/65538 and related issue https://github.com/Sithira/FlutterRadioPlayer/issues/21.