PlayerView onTouch getY()不会不断提供值

时间:2018-07-23 13:00:50

标签: java android exoplayer exoplayer2.x

我试图在滑动时实现音量更改,但最重要的是,我双击了实现手势的手势。 我正在使用ExoPlayer 2和 com.google.android.exoplayer2.ui.PlayerView ,父级是 com.google.android.exoplayer2.ui.AspectRatioFrameLayout

我有code这样的人:

float y = motionEvent.getY();
int action = motionEvent.getActionMasked();
switch (action) {
    case MotionEvent.ACTION_DOWN:
        iY = y;
        break;
    case MotionEvent.ACTION_MOVE:
        float deltaY = motionEvent.getY() - iY;
        float absDeltaY = Math.abs(deltaY);
        if (isFullscreen) {
            Log.e("Delta", "Y: " + deltaY);
            Log.e("AbsDelta", "Y: " + absDeltaY);
            if (absDeltaY > 50) {
                Log.e("action", "Swipe !!!");
            }
        }
        break;
}
然后在onTouchListener中出现

gestureDetector.onTouchEvent(motionEvent);
return true;

gestureDetector是 GestureDetector.SimpleOnGestureListener ,它具有onDoubleTap和其他侦听器...

问题在于deltaY永远不会超过50个阈值,并且会停止并且需要重新触摸视图。另一方面,在与PlayerView及其父视图无关的视图上,它的作用就像是魅力。

P.S 这是多次触摸和滑动的日志记录:

07-23 16:32:08.879 20932-20932/test.test E/Delta: Y: -0.67178345
07-23 16:32:08.879 20932-20932/test.test E/AbsDelta: Y: 0.67178345
07-23 16:32:08.896 20932-20932/test.test E/Delta: Y: -1.6026917
07-23 16:32:08.896 20932-20932/test.test E/AbsDelta: Y: 1.6026917
07-23 16:32:08.915 20932-20932/test.test E/Delta: Y: -2.527893
07-23 16:32:08.915 20932-20932/test.test E/AbsDelta: Y: 2.527893
07-23 16:32:08.929 20932-20932/test.test E/Delta: Y: -2.8125
07-23 16:32:08.929 20932-20932/test.test E/AbsDelta: Y: 2.8125
07-23 16:32:10.471 20932-20932/test.test E/Delta: Y: 1.5309906
07-23 16:32:10.471 20932-20932/test.test E/AbsDelta: Y: 1.5309906
07-23 16:32:10.486 20932-20932/test.test E/Delta: Y: 3.1208649
07-23 16:32:10.486 20932-20932/test.test E/AbsDelta: Y: 3.1208649
07-23 16:32:10.503 20932-20932/test.test E/Delta: Y: 12.975586
07-23 16:32:10.503 20932-20932/test.test E/AbsDelta: Y: 12.975586
07-23 16:32:10.520 20932-20932/test.test E/Delta: Y: 23.091217
07-23 16:32:10.520 20932-20932/test.test E/AbsDelta: Y: 23.091217
07-23 16:32:12.178 20932-20932/test.test E/Delta: Y: -1.0716248
07-23 16:32:12.178 20932-20932/test.test E/AbsDelta: Y: 1.0716248
07-23 16:32:12.195 20932-20932/test.test E/Delta: Y: -1.640625
07-23 16:32:12.195 20932-20932/test.test E/AbsDelta: Y: 1.640625
07-23 16:32:12.211 20932-20932/test.test E/Delta: Y: -2.7798767
07-23 16:32:12.211 20932-20932/test.test E/AbsDelta: Y: 2.7798767
07-23 16:32:12.228 20932-20932/test.test E/Delta: Y: -4.5023193
07-23 16:32:12.228 20932-20932/test.test E/AbsDelta: Y: 4.5023193
07-23 16:32:12.244 20932-20932/test.test E/Delta: Y: -6.4189453
07-23 16:32:12.244 20932-20932/test.test E/AbsDelta: Y: 6.4189453
07-23 16:32:12.261 20932-20932/test.test E/Delta: Y: -14.851379
07-23 16:32:12.261 20932-20932/test.test E/AbsDelta: Y: 14.851379
07-23 16:32:12.278 20932-20932/test.test E/Delta: Y: -21.367462
07-23 16:32:12.278 20932-20932/test.test E/AbsDelta: Y: 21.367462
07-23 16:32:13.181 20932-20932/test.test E/Delta: Y: -0.68240356
07-23 16:32:13.182 20932-20932/test.test E/AbsDelta: Y: 0.68240356
07-23 16:32:13.198 20932-20932/test.test E/Delta: Y: -1.6026611
07-23 16:32:13.199 20932-20932/test.test E/AbsDelta: Y: 1.6026611
07-23 16:32:13.215 20932-20932/test.test E/Delta: Y: -3.2275085
07-23 16:32:13.215 20932-20932/test.test E/AbsDelta: Y: 3.2275085
07-23 16:32:13.231 20932-20932/test.test E/Delta: Y: -5.7579346
07-23 16:32:13.232 20932-20932/test.test E/AbsDelta: Y: 5.7579346
07-23 16:32:13.248 20932-20932/test.test E/Delta: Y: -13.611542
07-23 16:32:13.248 20932-20932/test.test E/AbsDelta: Y: 13.611542
07-23 16:32:14.120 20932-20932/test.test E/Delta: Y: -0.87713623
07-23 16:32:14.120 20932-20932/test.test E/AbsDelta: Y: 0.87713623
07-23 16:32:14.136 20932-20932/test.test E/Delta: Y: -1.8153687
07-23 16:32:14.137 20932-20932/test.test E/AbsDelta: Y: 1.8153687
07-23 16:32:14.152 20932-20932/test.test E/Delta: Y: -2.7530518
07-23 16:32:14.152 20932-20932/test.test E/AbsDelta: Y: 2.7530518
07-23 16:32:14.169 20932-20932/test.test E/Delta: Y: -4.1118164
07-23 16:32:14.170 20932-20932/test.test E/AbsDelta: Y: 4.1118164
07-23 16:32:14.185 20932-20932/test.test E/Delta: Y: -5.9500732
07-23 16:32:14.186 20932-20932/test.test E/AbsDelta: Y: 5.9500732
07-23 16:32:14.204 20932-20932/test.test E/Delta: Y: -16.7305
07-23 16:32:14.204 20932-20932/test.test E/AbsDelta: Y: 16.7305

0 个答案:

没有答案