MediaSessionService Never Destroy, Once App is Cleared Without Pausing Media
@marcbaechinger is already working on this.
Since Mar 19, 2024.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 1.2.1
When Media started to play, Now When User Close the app and Clear The Notification on this Scenario The Service never gets Destroyed.
Yeah I know we can clear Mediasession from service via onTaskRemoved but this works only when player is not playing, If Player is not playing currently and user try to close the app Then the Service get's destroyed. If Player is still running than the service won't get Destroyed,
Even I tried This Case When User Try to Close the App from onTaskRemoved I forcing the playing to stop and clear MediaSession Still Service keeps Running
override fun onTaskRemoved(rootIntent: Intent?) {
exoPlayer.pause()
stopSelf()
super.onTaskRemoved(rootIntent)
}
private fun clearMediaSession() {
mediaSession?.run {
player.release()
release()
}
}
override fun onDestroy() {
clearMediaSession()
clearListener()
super.onDestroy()
}
The Same Code Before Closing the app if player is Paused Then the Server will get Destroyed if player still playing Service Wont Destroy.
The Same Functionality is happening in Media3 Demo-Session Player as well.
On This Scenario How to Destroy The Service, Due to this App Consuming More Battery!!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.