Skip to content

Commit

Permalink
link #4050
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Nov 12, 2024
1 parent d416ce5 commit f6b5e36
Showing 1 changed file with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -19,6 +22,8 @@
public class LandLayoutVideo extends StandardGSYVideoPlayer {

private boolean isLinkScroll = false;
ScaleGestureDetector scaleGestureDetector;
float scaleFactor;

/**
* 1.5.0开始加入,如果需要不同布局区分功能,需要重载
Expand Down Expand Up @@ -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);
Expand All @@ -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() {
Expand Down

0 comments on commit f6b5e36

Please sign in to comment.