这是indexloc提供的服务,不要输入任何密码
Skip to content

Add flag to onPlaybackResumption to indicate whether playback should be started or not. #1764

@kelmer44

Description

@kelmer44

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions