Skip to content

Commit

Permalink
Merge pull request #1653 from theskyblockman:main
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 675277275
  • Loading branch information
copybara-github committed Sep 16, 2024
2 parents 47d45a8 + 25bb8e4 commit 6632e64
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
5 changes: 5 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
`PlayerView.setEnableComposeSurfaceSyncWorkaround` in order to opt-in
([#1237](https://github.com/androidx/media/issues/1237),
[#1594](https://github.com/androidx/media/issues/1594)).
* Add `setFullscreenButtonState` to `PlayerView` to allow updates of
fullscreen button's icon on demand, i.e. out-of-band and not reactively
to a click interaction
([#1590](https://github.com/androidx/media/issues/1590),
[#184](https://github.com/androidx/media/issues/184)).
* Downloads:
* OkHttp Extension:
* Cronet Extension:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1575,15 +1575,30 @@ private void seekToTimeBarPosition(Player player, long positionMs) {
}

private void onFullScreenButtonClicked(View v) {
if (onFullScreenModeChangedListener == null) {
updateIsFullscreen(!isFullScreen);
}

/**
* Updates whether the controller is in fullscreen, changing its fullscreen icon and reports it to
* to the listener.
*
* <p>For {@code isFullscreen} equals {@code true} the icon will be set to
* {@code @drawable/exo_styled_controls_fullscreen_exit} or else
* {@code @drawable/exo_styled_controls_fullscreen_enter}.
*
* @param isFullscreen If the view is in full screen.
*/
public void updateIsFullscreen(boolean isFullscreen) {
if (this.isFullScreen == isFullscreen) {
return;
}

isFullScreen = !isFullScreen;
updateFullScreenButtonForState(fullScreenButton, isFullScreen);
updateFullScreenButtonForState(minimalFullScreenButton, isFullScreen);
this.isFullScreen = isFullscreen;
updateFullScreenButtonForState(fullScreenButton, isFullscreen);
updateFullScreenButtonForState(minimalFullScreenButton, isFullscreen);

if (onFullScreenModeChangedListener != null) {
onFullScreenModeChangedListener.onFullScreenModeChanged(isFullScreen);
onFullScreenModeChangedListener.onFullScreenModeChanged(isFullscreen);
}
}

Expand Down
15 changes: 15 additions & 0 deletions libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,21 @@ public void setFullscreenButtonClickListener(@Nullable FullscreenButtonClickList
controller.setOnFullScreenModeChangedListener(componentListener);
}

/**
* Sets whether the player is currently in fullscreen, this will change the displayed icon.
*
* <p>If {@code isFullscreen} is {@code true},
* {@code @drawable/exo_styled_controls_fullscreen_exit} will be displayed or else
* {@code @drawable/exo_styled_controls_fullscreen_enter}.
*
* @param isFullscreen Whether the player is currently in fullscreen.
*/
@UnstableApi
public void setFullscreenButtonState(boolean isFullscreen) {
Assertions.checkStateNotNull(controller);
controller.updateIsFullscreen(isFullscreen);
}

/**
* Sets the {@link PlayerControlView.OnFullScreenModeChangedListener}.
*
Expand Down

0 comments on commit 6632e64

Please sign in to comment.