-
Notifications
You must be signed in to change notification settings - Fork 574
Description
Use case description
MediaLibrarySessionCallback
's onPlaybackResumption
is called from MediaSession.handleMediaControllerPlayRequest
to handle incoming play requests from MediaControllers, or from MediaLibrarySession.getRecentMediaItemAtDeviceBootTime
to populate the media notification at boot time. While the former should end up with playback (or else resulting in a ForegroundServiceDidNotStartInTimeException
), the latter should never explicitly call playback to avoid playing content upon device reboot.
Although for simpler cases media3 can handle this situation internally, for more complex cases where playback can't be resolved by merely returning a list of MediaItems in onPlaybackResumption
, it would be useful to have a way to determine within this function whether the call should result in playback or not.
Proposed solution
onPlaybackResumption
may have an extra boolean parameter to indicate this situation, or the incoming controller info might contain an indication that the request is coming from MediaLibrary to populate the last media sesion within the OS.
Alternatives considered
I currently inspect the call stack to reach this conclusion but this is hacky and far from ideal.