stopBackgroundDisplay method
Clears the display of the OS's background audio display.
On Android, this dismisses the notification (and clears all Android media buttons, metadata, and supported actions). You will need to re-set those elements, and call Audio.play() on a background-enabled Audio, to bring back the notification.
On iOS, this clears the supported controls and metadata from the lockscreen/control center. However, the lockscreen will continue to display an empty set of controls with the name of the app. Call setMetadata or setSupportedMediaActions to bring back the display.
Note that any background audio playback will continue. On Android, this means that audio will continue despite no visible notification from a foreground Service; this appears to be an undocumented behavior of Android's MediaBrowserService, in that it keeps the connected Activity (and its associated Dart process) active.
Implementation
void stopBackgroundDisplay() async {
try {
await audioMethodChannel
.invokeMethod<dynamic>(stopBackgroundDisplayMethod);
} on PlatformException catch (e) {
_logger.severe('stopBackgroundDisplay error', e);
}
}