Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 13: Unable To Ensure The Availability Of Commands Via getAvailableCommands() #256

Closed
y20k opened this issue Feb 24, 2023 · 2 comments
Assignees

Comments

@y20k
Copy link

y20k commented Feb 24, 2023

Media3 Version

1.0.0-rc01

Devices that reproduce the issue

  • Pixel 4a Emulator API 33

Reproducible in the demo app?

Not tested

Reproduction steps

Setting

  • a podcast app that plays a single media item
  • you want to offer the user a Seek To Next option even though there is no next media item

Proposed solution in #249

Use a ForwardingPlayer that wraps the actual player, override getAvailableCommands() and add COMMAND_SEEK_TO_NEXT to the available commands. This is how I implemented that.

val forwardingPlayer = object : ForwardingPlayer(player) {
    override fun getAvailableCommands(): Player.Commands {
        return super.getAvailableCommands().buildUpon()
            .add(Player.COMMAND_SEEK_TO_NEXT)
            .build()
    }
}

Expected result

  • the MediaSession and the Notification both offer Seek To Next
  • a MediaSession.Callback receives in onPlayerCommandRequest the command Player.COMMAND_SEEK_TO_NEXT when a user tapped on Seek To Next

Actual result

Player.COMMAND_SEEK_TO_NEXT in onPlayerCommandRequest received, when user taps on Seek To Next?

Android 12 Android 13
1.0.0-beta03 yes yes
1.0.0-rc01 no ❌ no ❌
@christosts
Copy link
Contributor

On your ForwardingPlayer, can you also override method isCommandAvailable(@Command int command) to return getAvailableCommands().contains(command)?

@y20k
Copy link
Author

y20k commented Feb 28, 2023

Hi @christosts, your suggestion solved the problem for me. Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants