Merge pull request #1653 from theskyblockman:main

PiperOrigin-RevId: 675277275
This commit is contained in:
Copybara-Service 2024-09-16 13:52:55 -07:00
commit 6632e64007
3 changed files with 40 additions and 5 deletions

View File

@ -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:

View File

@ -1575,15 +1575,30 @@ public class PlayerControlView extends FrameLayout {
}
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);
}
}

View File

@ -1139,6 +1139,21 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
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}.
*