四 自定义SurfaceView
为什么不直接用SurfaceView而是自定义?
如果想实现触摸滑动事件,就必须自定义。
自定义SurfaceView需要继承SurfaceView,我们现在的需求是滑动触控。
罗列出这几种情况:
亮度手势,手指在SurfaceView左半部上下滑动时候调用
2.音量手势,手指在SurfaceView右半部上下滑动时候调用
3.快进快退手势,手指在SurfaceView左右滑动的时候调用
4.按下手势,第一根手指按下时候调用
5.快进快退执行后的松开时候调用
我就这几种情况创建了一个接口 :VideoGesureListener
public interface VideoGesureListener{
//亮度手势,手指在SurfaceView左半部上下滑动时候调用
public void onBrightnessGesture(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
//音量手势,手指在SurfaceView右半部上下滑动时候调用
public void onVolumeGesture(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
//快进快退手势,手指在SurfaceView左右滑动的时候调用
public void onFF_REWGesture(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
//按下手势,第一根手指按下时候调用
public void onDown(MotionEvent e);