Motionlayout With Exoplayer Handle Touch Events Not Properly
I have OnSwipe animation in Motion Layout and a ExoPlayer. But when exoplayer is playing, motion layout animation not working. I think ExoPlayer intercepting touch events. How can
Solution 1:
There is a simple Way of doing that Extends the MotionLayout class and by overriding the
onInterceptTouchEvent()
@OverridepublicbooleanonInterceptTouchEvent(MotionEvent event) {
if (onTouchEvent(event)) {
returnfalse;
} else {
returntrue;
}
}
this is a simplest way to pass Childs touch event to parent or to background layout. this will resolve your issue.
Solution 2:
I solved that problem by creating custom player view. The problem is PlayerView intercepting the touch event, so motion layout don't get any touch event. By changing return value at PlayerView.onTouchEvent from true to false, the motion layout can handle the swipe event.
internalclassCustomExoPlayerView(
context: Context, attributeSet: AttributeSet? = null
) : PlayerView(context, attributeSet) {
@SuppressLint("ClickableViewAccessibility")overridefunonTouchEvent(event: MotionEvent): Boolean {
when (event.action) {
MotionEvent.ACTION_DOWN -> {
showController()
}
}
returnfalse
}
}
Post a Comment for "Motionlayout With Exoplayer Handle Touch Events Not Properly"