Rename setShowPlayButtonIfPlaybackIsSuppressed in MediaSession.Builder
Open
Nobody has claimed this yet.
enhancement
needs triage
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
[REQUIRED] Use case description
Please consider renaming setShowPlayButtonIfPlaybackIsSuppressed of MediaSession.Builder as the intent is more closely related to playback state when playback is suppressed.
https://developer.android.com/reference/androidx/media3/session/MediaSession.Builder#setShowPlayButtonIfPlaybackIsSuppressed(boolean)
For instance, playIfSuppressed is used to get the current playback state which is eventually exposed to media controllers.
/** Converts {@link Player}' states to state of {@link PlaybackStateCompat}. */
@PlaybackStateCompat.State
public static int convertToPlaybackStateCompatState(Player player, boolean playIfSuppressed) {
if (player.getPlayerError() != null) {
return PlaybackStateCompat.STATE_ERROR;
}
@Player.State int playbackState = player.getPlaybackState();
boolean shouldShowPlayButton = Util.shouldShowPlayButton(player, playIfSuppressed);
switch (playbackState) {
case Player.STATE_IDLE:
return PlaybackStateCompat.STATE_NONE;
case Player.STATE_READY:
return shouldShowPlayButton
? PlaybackStateCompat.STATE_PAUSED
: PlaybackStateCompat.STATE_PLAYING;
case Player.STATE_ENDED:
return PlaybackStateCompat.STATE_STOPPED;
case Player.STATE_BUFFERING:
return shouldShowPlayButton
? PlaybackStateCompat.STATE_PAUSED
: PlaybackStateCompat.STATE_BUFFERING;
default:
throw new IllegalArgumentException("Unrecognized State: " + playbackState);
}
}
Proposed solution
setPlaybackStateAsPausedIfPlaybackIsSuppressed or a better name. Internally, it could also imply an obvious side-effect on UI buttons.
Alternatives considered
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.