0

Code:

  audioHandler = await AudioService.init(
    builder: () => AudioPlayerHandler(),
    config: const AudioServiceConfig(
      androidNotificationChannelId: 'com.ryanheise.myapp.channel.audio',
      androidNotificationChannelName: 'Audio playback',
      androidNotificationOngoing: true,
      androidStopForegroundOnPause: true,
    ),
  );

Desired behaviour:

  • notification is persistent and can't be swiped away

  • when playback is paused, notification can be swiped away

Actual behaviour:

  • notification can always be swiped away
niclas_4
  • 3,514
  • 1
  • 18
  • 49
  • Can you add ```AndroidManifest.xml``` file code here . And i hope you have added ```android:foregroundServiceType="mediaPlayback"``` . you can follow this tutorial https://suragch.medium.com/background-audio-in-flutter-with-audio-service-and-just-audio-3cce17b4a7d – jayesh gurudayalani May 29 '23 at 15:23
  • @jayeshgurudayalani thanks for the reply, I checked the tutorial and have the same androidmanifest content – niclas_4 May 30 '23 at 16:09
  • Okay .. I think i got the reason .. I think it is because of ```androidStopForegroundOnPause: true``` as in doc it is mentioned that it is making your service low priority and allow to swipe notification .. https://pub.dev/documentation/audio_service/latest/audio_service/AudioServiceConfig-class.html – jayesh gurudayalani May 30 '23 at 16:20

0 Answers0