Toggle playback controls according to standard Android click handling.

We currently toggle the view in onTouchEvent ACTION_DOWN which is non-standard
and causes problems when used in a ViewGroup intercepting touch events.

Switch to standard Android click handling instead which is also what most
other player apps are doing.

Issue:#5784
PiperOrigin-RevId: 245219728
This commit is contained in:
tonihei 2019-04-25 13:48:36 +01:00 committed by Oliver Woodman
parent 84e03aea70
commit 21b2a471bb
2 changed files with 17 additions and 4 deletions

View file

@ -6,6 +6,8 @@
even if they are listed lower in the `MediaCodecList`.
* Audio: fix an issue where not all audio was played out when the configuration
for the underlying track was changing (e.g., at some period transitions).
* UI: Change playback controls toggle from touch down to touch up events
([#5784](https://github.com/google/ExoPlayer/issues/5784)).
### 2.10.0 ###

View file

@ -303,6 +303,7 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
private boolean controllerHideDuringAds;
private boolean controllerHideOnTouch;
private int textureViewRotation;
private boolean isTouching;
public PlayerView(Context context) {
this(context, null);
@ -1039,11 +1040,21 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getActionMasked() != MotionEvent.ACTION_DOWN) {
return false;
public boolean onTouchEvent(MotionEvent event) {
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;
}
return performClick();
}
@Override