Disables play/pause button when there's nothing to play

PiperOrigin-RevId: 502571320
(cherry picked from commit 345f2345c74ccbbf3dd49f125b1b81938b0a9995)
This commit is contained in:
Googler 2023-01-17 14:42:18 +00:00 committed by christosts
parent 4b3c74fb37
commit cebc0fa374

View File

@ -986,6 +986,9 @@ public class StyledPlayerControlView extends FrameLayout {
((ImageView) playPauseButton)
.setImageDrawable(getDrawable(getContext(), resources, drawableRes));
playPauseButton.setContentDescription(resources.getString(stringRes));
boolean enablePlayPause = shouldEnablePlayPauseButton();
updateButton(enablePlayPause, playPauseButton);
}
}
@ -1503,6 +1506,10 @@ public class StyledPlayerControlView extends FrameLayout {
}
}
private boolean shouldEnablePlayPauseButton() {
return player != null && !player.getCurrentTimeline().isEmpty();
}
private boolean shouldShowPauseButton() {
return player != null
&& player.getPlaybackState() != Player.STATE_ENDED