Skip to content

Confusion about Media3 service lifecycle and playback resumption #1249

@OxygenCobalt

Description

@OxygenCobalt

Currently, my app operates on a playback service lifecycle like this:

  • Service will attempt to load any persisted playback state on startup
  • Service only starts it's foreground state when the player starts playing
  • Service remains in it's foreground state indefinitely until the user explicitly exits it through either removing the task or clicking the close button on the notification

While attempting to re-architecture it around media3, I'm running into some very deep confusion about the way it works with MediaSessionService. As far as I am aware

  • Service will go foreground the moment you add a session
  • Service will exit foreground on task removal or spontaneously if the activity isn't in the foreground
  • Playback resumption plays some confusing role in here that interferes with my own persistence at a lot of points

I can't tell if this is the way the service is meant to behave or if it's a configuration problem on my part. Ideally I want to retain my old service lifecycle, as it's much more straightforward to manage with the other foreground service work I have to do, and it's what users are currently used to. However, if this is more ideal, I guess I can use it if there was more details on how the service is supposed to be behaving. Any help here would be appreciated.

Also related to #1246 somewhat, since it's also about having to reconcile my self-rolled lifecycle and Media3's.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions