Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
768 stars 305 forks source link

Restart foreground service after pause #861

Closed sschaub closed 2 years ago

sschaub commented 2 years ago

:sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Bug fix

:arrow_heading_down: What is the current behavior?

App is killed for excessive CPU use when it is playing audio in the background and the foreground service is not running

:boom: Does this PR introduce a breaking change?

No

:bug: Recommendations for testing

See repro steps for issue #860

:memo: Links to relevant issues/docs

Addresses issue #860

:thinking: Checklist before submitting

sschaub commented 2 years ago

This PR is based on the technique used in Google's Uamp demo project to restart the foreground service when needed:

https://github.com/android/uamp/blob/main/common/src/main/java/com/example/android/uamp/media/MusicService.kt