media
media copied to clipboard
Unable to resume playback in onPlayWhenReadyChanged (Player.Listener)
Media3 Version
1.0.0-beta02
Devices that reproduce the issue
- Emulator Pixel 5 API 33
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
- in a
MediaSessionService
create a Player with the attributesetPauseAtEndOfMediaItems(true)
- start playback of
MediaItem
A - unbind the service from its activty (kill the activity for example)
- listen in
onPlayWhenReadyChanged
(Player.Listener) for the reason (int)Player.PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM
- load a new
MediaItem
B whenPlayer.PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM
- start playback of new *MediaItem` B
Expected result
Player resumes playback with the MediaItem B.
Actual result
The app crashes and throws ForegroundServiceStartNotAllowedException
(android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service org.y20k.escapepod/.PlayerService).
Problem / my explanation: setPauseAtEndOfMediaItems(true)
pauses the player. If the service is not bound to an activity and playback is paused, media3 makes the service call stopForeground(true)
- probably here.
I think, once paused a MediaSessionService cannot start playback again by itself. A solution might be #45.
Media
Not applicable
Bug Report
- [X] You will email the zip file produced by
adb bugreport
to [email protected] after filing this issue.
I just wanted to let you know that I found a solution to my specific problem. The problem
once paused a MediaSessionService cannot start playback again by itself
might still be an issue for other uses cases than mine.
Thanks for the detailed report.
You are mentioning issue #45 that has some comments explaining the design decision of taking the service off the foreground when the player is paused by default. The justification for this is mainly system health.
By default
means that an app can override MediaSessionService.updateNotification(MediaSession)
and manage foreground handling itself.
Hi @marcbaechinger
Thanks for explaining the default behavior and the customization options to circumvent the problem I observed.
This is not a bug.