ryanheise / audio_service

Flutter plugin to play audio in the background while the screen is off.
805 stars 480 forks source link

Adding an option in AudioServiceConfig to switch to lower priority state on AudioProcessingState.completed #1053

Open skiluk opened 11 months ago

skiluk commented 11 months ago

Feature proposal

This would work similar to androidStopForegroundOnPause except stopForeground and stopSelf would be triggered when AudioProcessingState.completed.

Motivating use case(s)

We have an app that uses multiple audio files to play to the user in one stream of audio. Throughout this process we pause/unpause so the androidStopForegroundOnPause causes issues when playing in background as we do not have permissions to startForeground from the background. Using this feature would allow the notification to be dismissed when the audio is completed.

I have a PR almost completed for this feature if you would like me to submit

skiluk commented 11 months ago

PR added here

Mordtimer commented 9 months ago

@ryanheise wouldn't the proposed PR solve https://github.com/ryanheise/audio_service/issues/996 (and many other duplicates of it) at the same time?

You will not need to worry about pausing audio during interruption because of not having permissions to startForeground from the background in Android 12 +.

ryanheise commented 9 months ago

Hi @Mordtimer , there are further discussion points raised in that PR (if you don't mind, you would be welcome to comment on those discussion points over on that PR).