Open popivyurii opened 1 year ago
So I'm looking for a solution to close the app and free all resources when swiping from recents or clicking on custom button in notification.
When the app should be stopped when the task is removed:
override fun onTaskRemoved(rootIntent: Intent?) {
player.release()
mediaLibrarySession.release()
stopSelf()
}
If the service should continue in background:
override fun onTaskRemoved(rootIntent: Intent?) {
If (!player.playWhenReady) {
stopSelf()
}
}
sometimes the service restarts itself. Why does it happen?
Because the service returns START_STICKY
with onStartCommand()
.
Media3 Version
Media3 1.1.0-alpha01
Devices that reproduce the issue
Pixel 4 API 33 or any device
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
Launch the demo-session app. Play any song.
We have this code here
The question is how to close the app when I swipe the app from recents? If I remove this check
if (!player.playWhenReady)
and callstopSelf()
app is leaking. App is not visible in recents but android studio profiler shows that it is running and the service still takes memory.Adding
player.stop()
beforestopSelf()
inonTaskRemoved(rootIntent: Intent?)
also not helping. So I'm looking for a solution to close the app and free all resources when swiping from recents or clicking on custom button in notification.One more question. When killing the app by
sometimes the service restarts itself. Why does it happen?
Expected result
I need a way to close the app and free memory in both cases when Exoplayer is playing/paused.
Actual result
Demo app release resources only when exoplayer is paused.
!player.playWhenReady
Media
Bug Report
adb bugreport
to dev.exoplayer@gmail.com after filing this issue.