Rollback of 98e039d872
*** Original commit ***
Rollback of aa22bc2dbe
*** Original commit ***
Fix PlayerView touch handling
Overriding onTouchEvent was causing multiple issues, and
appears to be unnecessary. Removing the override fixes:
1. StyledPlayerView accessibility issue where "hide player
controls" actually toggled play/pause.
2. Delivery of events to a registered OnClick...
***
PiperOrigin-RevId: 434502423
This commit is contained in:
parent
06da55527f
commit
29fb77ea3a
@ -18,6 +18,16 @@
|
||||
* Extractors:
|
||||
* Matroska: Parse `DiscardPadding` for Opus tracks.
|
||||
* UI:
|
||||
* Fix delivery of events to `OnClickListener`s set on `PlayerView` and
|
||||
`LegacyPlayerView`, in the case that `useController=false`
|
||||
([#9605](https://github.com/google/ExoPlayer/issues/9605)). Also fix
|
||||
delivery of events to `OnLongClickListener` for all view configurations.
|
||||
* Fix incorrectly treating a sequence of touch events that exit the bounds
|
||||
of `PlayerView` and `LegacyPlayerView` before `ACTION_UP` as a click
|
||||
([#9861](https://github.com/google/ExoPlayer/issues/9861)).
|
||||
* Fix `PlayerView` accessibility issue where it was not possible to
|
||||
tapping would toggle playback rather than hiding the controls
|
||||
([#8627](https://github.com/google/ExoPlayer/issues/8627)).
|
||||
* Rewrite `TrackSelectionView` and `TrackSelectionDialogBuilder` to work
|
||||
with the `Player` interface rather than `ExoPlayer`. This allows the
|
||||
views to be used with other `Player` implementations, and removes the
|
||||
|
@ -431,6 +431,9 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
controller.hideImmediately();
|
||||
controller.addVisibilityListener(/* listener= */ componentListener);
|
||||
}
|
||||
if (useController) {
|
||||
setClickable(true);
|
||||
}
|
||||
updateContentDescription();
|
||||
}
|
||||
|
||||
@ -593,10 +596,14 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
* Sets whether the playback controls can be shown. If set to {@code false} the playback controls
|
||||
* are never visible and are disconnected from the player.
|
||||
*
|
||||
* <p>This call will update whether the view is clickable. After the call, the view will be
|
||||
* clickable if playback controls can be shown or if the view has a registered click listener.
|
||||
*
|
||||
* @param useController Whether the playback controls can be shown.
|
||||
*/
|
||||
public void setUseController(boolean useController) {
|
||||
Assertions.checkState(!useController || controller != null);
|
||||
setClickable(useController || hasOnClickListeners());
|
||||
if (this.useController == useController) {
|
||||
return;
|
||||
}
|
||||
@ -1015,30 +1022,10 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
return subtitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (!useController() || player == null) {
|
||||
return false;
|
||||
}
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
isTouching = true;
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (isTouching) {
|
||||
isTouching = false;
|
||||
return performClick();
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performClick() {
|
||||
super.performClick();
|
||||
return toggleControllerVisibility();
|
||||
toggleControllerVisibility();
|
||||
return super.performClick();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1134,18 +1121,15 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean toggleControllerVisibility() {
|
||||
private void toggleControllerVisibility() {
|
||||
if (!useController() || player == null) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
if (!controller.isFullyVisible()) {
|
||||
maybeShowController(true);
|
||||
return true;
|
||||
} else if (controllerHideOnTouch) {
|
||||
controller.hide();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Shows the playback controls, but only if forced or shown indefinitely. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user