From f6b5e36dae5593c13e1f8befde47efe48bae806e Mon Sep 17 00:00:00 2001 From: guoshuyu <359369982@qq.com> Date: Tue, 12 Nov 2024 10:24:21 +0800 Subject: [PATCH] link #4050 --- .../gsyvideoplayer/video/LandLayoutVideo.java | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/example/gsyvideoplayer/video/LandLayoutVideo.java b/app/src/main/java/com/example/gsyvideoplayer/video/LandLayoutVideo.java index ae874a6b5..19156c5db 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/video/LandLayoutVideo.java +++ b/app/src/main/java/com/example/gsyvideoplayer/video/LandLayoutVideo.java @@ -4,12 +4,15 @@ import android.util.AttributeSet; import android.view.GestureDetector; import android.view.MotionEvent; +import android.view.ScaleGestureDetector; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import com.example.gsyvideoplayer.R; +import com.shuyu.gsyvideoplayer.utils.Debuger; import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer; +import com.shuyu.gsyvideoplayer.video.base.GSYVideoControlView; import com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer; /** @@ -19,6 +22,8 @@ public class LandLayoutVideo extends StandardGSYVideoPlayer { private boolean isLinkScroll = false; + ScaleGestureDetector scaleGestureDetector; + float scaleFactor; /** * 1.5.0开始加入,如果需要不同布局区分功能,需要重载 @@ -51,9 +56,7 @@ public boolean onDoubleTap(MotionEvent e) { @Override public boolean onSingleTapConfirmed(MotionEvent e) { - if (!mChangePosition && !mChangeVolume && !mBrightness - && mCurrentState != CURRENT_STATE_ERROR - ) { + if (!mChangePosition && !mChangeVolume && !mBrightness && mCurrentState != CURRENT_STATE_ERROR) { onClickUiToggle(e); } return super.onSingleTapConfirmed(e); @@ -64,10 +67,35 @@ public void onLongPress(MotionEvent e) { super.onLongPress(e); } }); + + scaleGestureDetector = new ScaleGestureDetector(getContext().getApplicationContext(), new ScaleGestureDetector.SimpleOnScaleGestureListener() { + + @Override + public boolean onScale(ScaleGestureDetector detector) { + scaleFactor *= detector.getScaleFactor(); + scaleFactor = (scaleFactor < 1 ? 1 : scaleFactor); // prevent our view from becoming too small // + scaleFactor = ((float)((int)(scaleFactor * 100))) / 100; // Change precision to help with jitter when user just rests their fingers // + mTextureViewContainer.setScaleX(scaleFactor); + mTextureViewContainer.setScaleY(scaleFactor); + + return true; + } + }); + } }); } + @Override + public boolean onTouch(View v, MotionEvent event) { + //if (event.getPointerCount() > 1 && v.getId() == R.id.surface_container) { + if (event.getPointerCount() > 1) { + scaleGestureDetector.onTouchEvent(event); + return true; + } + return super.onTouch(v, event); + } + //这个必须配置最上面的构造才能生效 @Override public int getLayoutId() {