diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 1e154cb0e4..2e262e11d5 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -35,17 +35,6 @@ views to be used with other `Player` implementations, and removes the dependency from the UI module to the ExoPlayer module. This is a breaking change. -* UI: - * Fix delivery of events to `OnClickListener`s set on `StyledPlayerView` - and `PlayerView`, 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 `StyledPlayerView` and `PlayerView` before `ACTION_UP` as a click - ([#9861](https://github.com/google/ExoPlayer/issues/9861)). - * Fix `StyledPlayerView` 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)). * RTSP: * Add RTP reader for HEVC ([#36](https://github.com/androidx/media/pull/36)). diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java index f2a92963a3..d687a7943b 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java @@ -397,7 +397,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider { LayoutInflater.from(context).inflate(playerLayoutId, this); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); - setClickable(true); // Content frame. contentFrame = findViewById(R.id.exo_content_frame); @@ -1073,10 +1072,31 @@ 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; + performClick(); + return true; + } + return false; + default: + return false; + } + } + @Override public boolean performClick() { - toggleControllerVisibility(); - return super.performClick(); + super.performClick(); + return toggleControllerVisibility(); } @Override @@ -1172,15 +1192,16 @@ public class PlayerView extends FrameLayout implements AdViewProvider { return false; } - private void toggleControllerVisibility() { + private boolean toggleControllerVisibility() { if (!useController() || player == null) { - return; + return false; } if (!controller.isVisible()) { maybeShowController(true); } else if (controllerHideOnTouch) { controller.hide(); } + return true; } /** Shows the playback controls, but only if forced or shown indefinitely. */ diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java index 58c96b6c41..9f26068f05 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java @@ -311,7 +311,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { LayoutInflater.from(context).inflate(playerLayoutId, this); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); - setClickable(true); // Content frame. contentFrame = findViewById(R.id.exo_content_frame); @@ -1019,10 +1018,30 @@ public class StyledPlayerView 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() { - toggleControllerVisibility(); - return super.performClick(); + super.performClick(); + return toggleControllerVisibility(); } @Override @@ -1118,15 +1137,18 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { return false; } - private void toggleControllerVisibility() { + private boolean toggleControllerVisibility() { if (!useController() || player == null) { - return; + return false; } 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. */