How to properly reject a command received in `onPlayerCommandRequest`?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Hello,
Case is pretty simple - some of our content requires premium subscription, so before loading content to player we are validating if user has access to it. We are doing this on our side, so we can easily control it while it's not loaded to the player, but user might lose his access after items were loaded to the player. While user is using the app and controlling playback through MediaController we can stop him before commands are being sent to the service, but if user uses notification to control playback then we can only do that through onPlayerCommandRequest and this is where we come to an issue. We are looking for Player.COMMAND_PLAY_PAUSE and checking if user has access to play the content, if he/she doesn't then at the moment we stop the player and return SessionResult.RESULT_INFO_SKIPPED which then sadly leads to ForegroundServiceDidNotStartInTimeException because service was started but it never went to foreground because playWhenReady was never set to true. I've also tried returning SessionResult.RESULT_ERROR_PERMISSION_DENIED but it leads to the same outcome. So my question is how to properly reject commands that come from notification and avoid ForegroundServiceDidNotStartInTimeException?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.