0

I am using the package just_audio and audio_service in my Flutter app. To simplify: I have 5 buttons; each one has an audio file associated with it. When a button is pressed the corresponding audio starts and a popup opens. If the user closes the popup the audio stops.

When this line of code is executed:

audioManager.stop();

In the notification bar, the player remains and from there the user can play again.

I do not want the user to be able to do this.

The moment the user closes the popup, he must stop listening to music. He can only listen to it again after clicking on one of the 5 buttons.

How can I do this? Thank you

elle D
  • 25
  • 4
  • It depends on which phone and which version of Android you have - you need to specify. On some versions of Android on some phones, removing the notification simply doesn't work. (It has to do with Android's initially attempt to make it so that media sessions are persistent. They later fixed it so that you could remove the notification again, but some versions of Android may have never fixed it.) – Ryan Heise May 01 '23 at 13:45
  • Ok, I didn't know that, thanks for the explanation. I'm testing my code on an Android 10 and on an Android 12 but it behaves the same on both... – elle D May 02 '23 at 07:38
  • I would suggest you edit your question, and specify both the Android version and the device (e.g. which phone), so that someone can answer you. Or if noone answers, at least people will know which specific phone / version has the problem which would be helpful to others. – Ryan Heise May 03 '23 at 08:06

0 Answers0