mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00

Currently, as soon as the playback is considered disengaged (not ready and playing), the foreground service is stopped. This causes problems if the app or the user attempts to restart playback after a short amount of time, where apps may run into foreground service start restrictions. Almost all of these short-term interaction issues can be solved by keeping the foreground service running for an additional timeout period, which is chosen to be 10 minutes to match the behavior of future Android system enforcements. For any longer term interactions, apps need to implement playback resumption paths that can restart the service with the previous playback. One caveat is that we currently use player.pause() as a way to stop the foreground service in onTaskRemoved() if the app wants to abandon playback at this point. With the timeout, the service can no longer be stopped immediately just by calling pause(), so we need to explicitly disable the timeout in the corresponding helper method. Issue: androidx/media#1928 Issue: androidx/media#111 PiperOrigin-RevId: 726942625 (cherry picked from commit 8a888d0d1801ce018b5bca5dbab78be44507286e)