bluefireteam / audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
https://pub.dartlang.org/packages/audioplayers
MIT License
2.01k stars 845 forks source link

Audio not played when app is in the background for some time #1721

Open wujek-srujek opened 11 months ago

wujek-srujek commented 11 months ago

Checklist

Current bug behaviour

My app is a simple timer: I can define intervals and it runs them one by one, and when one is finished, the app makes a beep using this package, and goes on to the next interval; if the last interval is finished, it gives a slightly different beep.

I noticed that when the application is in the background, after some time (about 30 seconds?) the app doesn't play the beeps any more, even if their time elapses. When I go back to the app, it seems like it hung up at the very end of one of the intervals (the one that didn't beep) - I can see the timer - then it beeps immediately and goes on to the next interval. Basically, the app gets paused in the background when it's time to beep. This seems not to happen when I disable all sounds. The app has all battery optimizations turned off.

Is anybody aware of what could be going wrong? I could also be not related to this package, but rather some kind of Android-specific behavior, but I'm clueless.

Expected behaviour

The app continues beeping even if in the background.

Affected platforms

Android

AudioPlayers Version

5.2.1

Build mode

release

Gustl22 commented 11 months ago

I never tested that feature, but since it is not explicitely mentioned for Android in the troubleshooting guide, I think it should work by default.

Possible soltlutions are mentioned:

Unfortunately I have not the time to evaluate this. If you find a soltion, we are happy to mention this or review an implementation of it.

Voyage-He commented 2 months ago

same issues,with Use stayAwake in AndroidAudioContext options