Browse Source

Merge branch 'master' of http://116.62.119.248:10082/cheng_zq/EffectDemo into lwz_

LAPTOP-K69FCNBP\crius 2 years ago
parent
commit
8cb2b6f2d0

+ 5 - 0
.idea/jarRepositories.xml

@@ -36,5 +36,10 @@
       <option name="name" value="maven2" />
       <option name="url" value="https://repo1.maven.org/maven2/" />
     </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven3" />
+      <option name="name" value="maven3" />
+      <option name="url" value="https://maven.aliyun.com/repository/public" />
+    </remote-repository>
   </component>
 </project>

+ 2 - 0
.idea/misc.xml

@@ -8,6 +8,8 @@
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_count_down.xml" value="0.25" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_drag_select.xml" value="0.12708333333333333" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_enty_anim.xml" value="0.11979166666666667" />
+        <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_gsxy_video.xml" value="0.1" />
+        <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_ijkplay.xml" value="0.1390625" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_lottie.xml" value="0.1" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_main.xml" value="0.1375" />
         <entry key="..\:/Progect/gitee/EffectDemo/app/src/main/res/layout/activity_progress.xml" value="0.22" />

+ 37 - 1
app/build.gradle

@@ -20,7 +20,9 @@ android {
         versionName "1.0"
 
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-
+        ndk {
+            abiFilters "armeabi"
+        }
         manifestPlaceholders = [
                 JPUSH_PKGNAME : applicationId,
                 JPUSH_APPKEY : "ecffb33772bcb5b0a447c70b", //JPush 上注册的包名对应的 Appkey.
@@ -80,6 +82,20 @@ android {
     buildFeatures {
         viewBinding true
     }
+
+//    splits {
+//        abi {
+//            enable true
+//            reset()
+//            include 'x86', 'x86_64', 'armeabi-v7a', 'armeabi'
+//            universalApk false
+//        }
+//    }
+
+//    packagingOptions {
+//        pickFirst 'lib/armeabi-v7a/libnms.so'
+//    }
+
 }
 repositories {
     flatDir {
@@ -88,6 +104,7 @@ repositories {
 }
 
 
+
 dependencies {
     implementation 'androidx.appcompat:appcompat:1.3.0'
     implementation 'com.google.android.material:material:1.4.0'
@@ -95,6 +112,7 @@ dependencies {
     implementation 'androidx.navigation:navigation-fragment:2.3.5'
     implementation 'androidx.navigation:navigation-ui:2.3.5'
     implementation files('libs\\oraleval-android-sdk.jar')
+    implementation(name: 'source', ext: 'aar')
     testImplementation 'junit:junit:4.12'
     androidTestImplementation 'androidx.test.ext:junit:1.1.2'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
@@ -120,4 +138,22 @@ dependencies {
     implementation  'com.umeng.umsdk:uverify-crashshield:2.1.4'// 必选
 
     implementation 'com.google.code.gson:gson:2.8.5'
+
+//    //========ijkplaer Java部分依赖
+//    implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
+//    //google ExoPlayer播放的扩展,一般无需添加
+//    //implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
+//
+//    //========ijkplaer Native部分依赖(根据运行CPU的平台选择)
+//    //使用真机测试 添加以下依赖
+//    implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
+
+    //GSXY播放器
+//    implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer:v8.3.4-release-jitpack'
+    //是否需要AliPlayer模式
+//    implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer-aliplay:v8.3.4-release-jitpack'
+
+    //完整版引入
+    implementation 'com.shuyu:GSYVideoPlayer:8.1.2'
+
 }

BIN
app/libs/source.aar


BIN
app/libs/zxing-1.0.2.aar


+ 20 - 1
app/src/main/AndroidManifest.xml

@@ -16,6 +16,22 @@
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
 
+    <!-- 网络权限 -->
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
+
+    <!-- mirror -->
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
+
+    <!-- 推送本地媒体权限 -->
+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
+
+    <!-- 获取设备名称、蓝牙搜索(蓝牙搜索同时需要蓝牙权限和定位权限) -->
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+
+
     <application
         android:name=".App"
         android:allowBackup="true"
@@ -107,7 +123,10 @@
         <activity android:name=".yzs.YZSConfigActivity"/>
         <activity android:name=".yzs.YZSDemoActivity"/>
         <activity android:name=".activity.SongLyricActivity"/>
-
+        <activity android:name=".activity.IJKPlayerActivity"
+            android:screenOrientation="landscape" />
+        <activity android:name=".activity.GSXYVideoPlayerActivity"
+            android:screenOrientation="landscape" />
     </application>
 
 </manifest>

+ 9 - 0
app/src/main/java/com/xunao/effectdemo/App.java

@@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.util.Log;
 
+import com.hpplay.sdk.source.api.LelinkSourceSDK;
 import com.uc.crashsdk.export.CrashApi;
 import com.umeng.analytics.MobclickAgent;
 import com.umeng.commonsdk.UMConfigure;
@@ -40,6 +41,14 @@ public class App extends Application {
 		JPushInterface.setDebugMode(true);
 		JPushInterface.init(this);
 //		getSHA1Signature(this);
+
+	}
+
+	void initLebo(){
+//		LelinkSourceSDK.getInstance()
+//				//FIXME WARN: 这里替换为您申请的AppID & AppSecret,build.gradle替换为您的应用包名
+//				.setSdkInitInfo(this, getString(R.string.app_id), getString(R.string.app_secret))
+//				.easyPush(mBrowseContainer);
 	}
 
 	/**

+ 0 - 6
app/src/main/java/com/xunao/effectdemo/activity/DragSelectActivity.java

@@ -86,8 +86,6 @@ public class DragSelectActivity extends Activity {
 		rightAnim.setFillAfter(true);
 
 
-
-
 		view = findViewById(R.id.view);
 		imv1 = findViewById(R.id.imv_1);
 		seek = findViewById(R.id.seek);
@@ -116,7 +114,6 @@ public class DragSelectActivity extends Activity {
 						inY = view.getY();
 						break;
 					case MotionEvent.ACTION_MOVE:
-//
 						final float xDistance = event.getX() - downX;
 						final float yDistance = event.getY() - downY;
 						Log.e("MyTag","x:" + v.getLeft() + "  y:"+event.getY());
@@ -188,7 +185,6 @@ public class DragSelectActivity extends Activity {
 				imv1.setAlpha(setAlpha);
 			}
 			toScale = 2*setAlpha+1;
-			Log.e("MyTag","数组:"+toScale);
 			scaleAnim = new ScaleAnimation(scale, toScale, scale, toScale, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
 			scaleAnim.setDuration(0);
 			scale = toScale;
@@ -203,12 +199,10 @@ public class DragSelectActivity extends Activity {
 				view.startAnimation(rightAnim);
 			}
 			setAlpha = ((float)l-left)/left ;
-			Log.e("MyTag","设置透明度:"+setAlpha);
 			if (setAlpha>0.3){
 				imv2.setAlpha(setAlpha);
 			}
 			toScale = 2*setAlpha+1;
-			Log.e("MyTag","数组:"+toScale);
 			scaleAnim = new ScaleAnimation(scale, toScale, scale, toScale, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
 			scaleAnim.setDuration(0);
 			scale = toScale;

+ 98 - 0
app/src/main/java/com/xunao/effectdemo/activity/GSXYVideoPlayerActivity.java

@@ -0,0 +1,98 @@
+package com.xunao.effectdemo.activity;
+
+import android.app.Activity;
+import android.content.pm.ActivityInfo;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+
+import androidx.annotation.Nullable;
+
+import com.shuyu.gsyvideoplayer.GSYVideoManager;
+import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
+import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
+import com.xunao.effectdemo.R;
+import com.xunao.effectdemo.view.VideoPreviewPlay;
+
+/**
+ * author : 程中强
+ * e-mail : 740479946@qq.com
+ * date : 2022/9/1417:18
+ * desc :
+ * version: 1.0
+ */
+public class GSXYVideoPlayerActivity extends Activity {
+
+	VideoPreviewPlay videoPlayer;
+	private OrientationUtils orientationUtils;
+	private Button btn;
+	private boolean isFirst = false;
+	private String url = "http://v3.cztv.com/cztv/vod/2018/06/28/7c45987529ea410dad7c088ba3b53dac/h264_1500k_mp4.mp4";
+	@Override
+	protected void onCreate(@Nullable Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_gsxy_video);
+		init();
+	}
+
+	void init(){
+		videoPlayer = findViewById(R.id.video_play);
+		videoPlayer.setUp(url, true, "null");
+
+
+		//增加title
+		videoPlayer.getTitleTextView().setVisibility(View.GONE);
+		//设置返回键
+		videoPlayer.getBackButton().setOnClickListener(v->{
+			finish();
+		});
+		videoPlayer.getFullscreenButton().setVisibility(View.GONE);
+		orientationUtils = new OrientationUtils(this, videoPlayer);
+		videoPlayer.setIsFinish(isFirst);
+		videoPlayer.setIsTouchWiget(isFirst);
+		videoPlayer.setIsTouchWigetFull(isFirst);
+		videoPlayer.setIfCurrentIsFullscreen(false);
+		videoPlayer.startPlayLogic();
+
+		btn = findViewById(R.id.btn_finish);
+		btn.setOnClickListener(v->{
+			isFirst = !isFirst;
+			videoPlayer.setIsFinish(isFirst);
+//			videoPlayer.setIsTouchWiget(isFirst);
+//			videoPlayer.setIsTouchWigetFull(isFirst);
+		});
+	}
+
+	@Override
+	protected void onResume() {
+		super.onResume();
+		videoPlayer.onVideoResume();
+	}
+
+	@Override
+	protected void onPause() {
+		super.onPause();
+		videoPlayer.onVideoPause();
+	}
+
+	@Override
+	protected void onDestroy() {
+		super.onDestroy();
+		GSYVideoManager.releaseAllVideos();
+		if (orientationUtils != null)
+			orientationUtils.releaseListener();
+	}
+
+//	@Override
+//	public void onBackPressed() {
+//		//先返回正常状态
+//		if (orientationUtils.getScreenType() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
+//			videoPlayer.getFullscreenButton().performClick();
+//			return;
+//		}
+//		//释放所有
+//		videoPlayer.setVideoAllCallBack(null);
+//		super.onBackPressed();
+//	}
+}

+ 71 - 0
app/src/main/java/com/xunao/effectdemo/activity/IJKPlayerActivity.java

@@ -0,0 +1,71 @@
+package com.xunao.effectdemo.activity;
+
+import android.app.Activity;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+
+import androidx.annotation.Nullable;
+
+import com.xunao.effectdemo.R;
+
+import java.io.IOException;
+
+import tv.danmaku.ijk.media.player.IjkMediaPlayer;
+
+/**
+ * author : 程中强
+ * e-mail : 740479946@qq.com
+ * date : 2022/9/1314:34
+ * desc :
+ * version: 1.0
+ */
+public class IJKPlayerActivity extends Activity {
+
+	private SurfaceView showView;
+	private IjkMediaPlayer ijkMediaPlayer;
+	@Override
+	protected void onCreate(@Nullable Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_ijkplay);
+		showView = findViewById(R.id.surfaceView);
+
+		//创建IjkPlayer对象
+		ijkMediaPlayer = new IjkMediaPlayer();
+		//设置Surface创建以及发生变化的回调
+		showView.getHolder().addCallback(callback);
+	}
+
+	private SurfaceHolder.Callback callback = new SurfaceHolder.Callback() {
+		@Override
+		public void surfaceCreated(SurfaceHolder holder) {
+		}
+		@Override
+		public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+			//设置显示界面的Holder
+			ijkMediaPlayer.setDisplay(holder);
+			try {
+				//设置播放地址
+				ijkMediaPlayer.setDataSource(IJKPlayerActivity.this, Uri.parse("http://v3.cztv.com/cztv/vod/2018/06/28/7c45987529ea410dad7c088ba3b53dac/h264_1500k_mp4.mp4"),null);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			//播放前准备
+			ijkMediaPlayer.prepareAsync();
+			//开始播放
+			ijkMediaPlayer.start();
+		}
+		@Override
+		public void surfaceDestroyed(SurfaceHolder holder) {
+		}
+	};
+
+	@Override
+	protected void onDestroy() {
+		super.onDestroy();
+		if (ijkMediaPlayer!=null){
+			ijkMediaPlayer.stop();
+		}
+	}
+}

+ 6 - 1
app/src/main/java/com/xunao/effectdemo/activity/MainActivity.java

@@ -25,7 +25,7 @@ public class MainActivity extends Activity {
 
 	Button btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,
 			btn9,btn10,btn11,btn12,btn13, btn14,btn15,btn16,
-			btn17,btn18;
+			btn17,btn18,btn19;
 	Intent intent;
 
 	@Override
@@ -136,5 +136,10 @@ public class MainActivity extends Activity {
 			intent = new Intent(MainActivity.this, SongLyricActivity.class);
 			startActivity(intent);
 		});
+		btn19 = findViewById(R.id.btn_19);
+		btn19.setOnClickListener(v->{
+			intent = new Intent(MainActivity.this, GSXYVideoPlayerActivity.class);
+			startActivity(intent);
+		});
 	}
 }

+ 198 - 12
app/src/main/java/com/xunao/effectdemo/activity/SequentialDragActivity.java

@@ -1,18 +1,26 @@
 package com.xunao.effectdemo.activity;
 
+import android.animation.TypeEvaluator;
+import android.animation.ValueAnimator;
 import android.app.Activity;
 import android.content.ClipData;
+import android.graphics.PointF;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.DragEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.animation.DecelerateInterpolator;
 import android.widget.RelativeLayout;
 
 import androidx.annotation.Nullable;
 
 import com.xunao.effectdemo.R;
+import com.xunao.effectdemo.bean.ListBean;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * author : 程中强
@@ -26,6 +34,9 @@ public class SequentialDragActivity extends Activity {
 	private static String TAG = "SequentialDragActivity";
 	private RelativeLayout rl1,rl2,rl3,rl4,rl5;
 	private RelativeLayout view1,view2,view3,view4,view5;
+	private ListBean bean;
+	private List<ListBean> beanList = new ArrayList<>();//用于记录数据
+	private List<View> list = new ArrayList<>();
 	@Override
 	protected void onCreate(@Nullable Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
@@ -41,11 +52,16 @@ public class SequentialDragActivity extends Activity {
 		view3 = findViewById(R.id.view3);
 		view4 = findViewById(R.id.view4);
 		view5 = findViewById(R.id.view5);
-		setDrag(rl1,view1);
-		setDrag(rl2,view2);
-		setDrag(rl3,view3);
-		setDrag(rl4,view4);
-		setDrag(rl5,view5);
+		setTouchText(rl1);
+		setTouchText(rl2);
+		setTouchText(rl3);
+		setTouchText(rl4);
+		setTouchText(rl5);
+//		setDrag(rl1,view1);
+//		setDrag(rl2,view2);
+//		setDrag(rl3,view3);
+//		setDrag(rl4,view4);
+//		setDrag(rl5,view5);
 	}
 
 	private void setDrag(View view1,View view2){
@@ -75,14 +91,11 @@ public class SequentialDragActivity extends Activity {
 			Log.i(TAG, "container.onDrag called======");
 			switch (dragEvent.getAction()) {
 				case DragEvent.ACTION_DRAG_STARTED://开始.当有view被拖的时候收到此事件
-//                        Log.i(TAG, "开始");
 					((View) dragEvent.getLocalState()).setVisibility(View.INVISIBLE);
 					break;
 				case DragEvent.ACTION_DRAG_ENTERED://进入.当被拖view手指按压的位置进入本view的瞬间收到此事件
-//                        Log.i(TAG, "进入");
 					break;
 				case DragEvent.ACTION_DRAG_LOCATION://位于.当被拖view手指按压的位置在本view上方的时候收到此事件
-//                        Log.i(TAG, "位于");
 
 					//此时dragEvent里包含要被拖view
 					View draggingView = (View) dragEvent.getLocalState();
@@ -101,21 +114,194 @@ public class SequentialDragActivity extends Activity {
 					}
 					break;
 				case DragEvent.ACTION_DROP://丢入.当被拖view在本view上方手指释放开,收到此事件
-//                        Log.i(TAG, "丢入");
 					Log.i(TAG, "丢入view_container2");
 					break;
 				case DragEvent.ACTION_DRAG_EXITED://出去.当被拖view手指按压位置从本view拖出去收到此事件
-//                        Log.i(TAG, "出去");
 					break;
 				case DragEvent.ACTION_DRAG_ENDED://结束.手指释放拖拽结束收到此事件.
-//                        Log.i(TAG, "结束");
 					((View) dragEvent.getLocalState()).setVisibility(View.VISIBLE);
 					break;
 				default:
 					break;
 			}
-			//一定要为true
 			return true;
 		}
 	};
+
+	private float downX;
+	private float downY;
+	private long downTime;
+	private long delay;
+	private boolean isMove;
+	private boolean canDrag;
+	private int left,enfLeft;
+	private int top,endTop;
+	private boolean isClose = false;
+	void setTouchText(View view){
+		list.add(view);
+		view.setOnClickListener(v1->{});
+		view.setOnTouchListener(new View.OnTouchListener() {
+			@Override
+			public boolean onTouch(View v, MotionEvent event) {
+				switch (event.getAction()) {
+					case MotionEvent.ACTION_DOWN:
+						downX = event.getX();
+						downY = event.getY();
+						isMove = false;
+						downTime = System.currentTimeMillis();
+						top = v.getTop();
+						left = v.getLeft();
+						canDrag = true;
+						v.bringToFront();
+						break;
+					case MotionEvent.ACTION_MOVE:
+
+						if (!canDrag) {
+							break;
+						}
+						final float xDistance = event.getX() - downX;
+						final float yDistance = event.getY() - downY;
+						enfLeft = (int)v.getX()-left;
+						endTop = (int)v.getY()-top;
+						Log.e("MyTag","x:"+enfLeft+"   y:"+endTop);
+						if (xDistance != 0 && yDistance != 0) {
+							int l = (int) (v.getLeft() + xDistance);
+							int r = (int) (l + v.getWidth());
+							int t = (int) (v.getTop() + yDistance);
+							int b = (int) (t + v.getHeight());
+							v.setLeft(l);
+							v.setTop(t);
+							v.setRight(r);
+							v.setBottom(b);
+							isMove = true;
+						}
+
+						break;
+					case MotionEvent.ACTION_UP:
+
+						int l = left;
+						int r = (int) (l + v.getWidth());
+						int t = top;
+						int b = (int) (t + v.getHeight());
+
+						v.setLeft(l);
+						v.setTop(t);
+						v.setRight(r);
+						v.setBottom(b);
+						judgeView(v,enfLeft,endTop);
+						isClose = false;
+						break;
+					default:
+						break;
+				}
+				return isMove;
+			}
+		});
+	}
+
+	private void judgeView(View view,int left,int top){
+		for (ListBean b:beanList){
+			if (b.getView().getId() != view.getId()){
+				if (Math.abs(b.getView().getX()-left)<50&&
+						Math.abs(b.getView().getY()-top)<50){
+					changeToView((ViewGroup)view,b.getView(),0);
+				}
+			}
+		}
+	}
+	//交换2个view
+	private void changeToView(ViewGroup v1p,ViewGroup v2p,int time){
+
+		int num;
+		for (ListBean b:beanList){
+			if (b.getView().getId() == v1p.getId()){
+				num = b.getNum();
+				for (ListBean b2:beanList){
+					if (b2.getView().getId() == v2p.getId()){
+						b.setNum(b2.getNum());
+						b2.setNum(num);
+					}
+				}
+			}
+		}
+		moveToWord(v2p,v1p,time);
+		moveToWord(v1p,v2p,time);
+	}
+
+	private void moveToWord(View view, View targetView,int time) {
+		final float x = view.getX();
+		final float y = view.getY();
+
+		final float targetX = targetView.getX();
+		final float targetY = targetView.getY();
+		ValueAnimator valueAnimator = new ValueAnimator();
+		valueAnimator.setDuration(time);//600
+		valueAnimator.setObjectValues(new PointF(x, y));
+		valueAnimator.setInterpolator(new DecelerateInterpolator());
+		//首先判断 目标点在上还是在下
+		final boolean flagX = ((x - targetX) > 0) ? true : false;
+		final boolean flagY = ((y - targetY) > 0) ? true : false;
+		valueAnimator.setEvaluator(new TypeEvaluator<PointF>() {
+			@Override
+			public PointF evaluate(float fraction, PointF startValue,
+								   PointF endValue) {
+				//从0.0 --->>   1.0
+				PointF point = new PointF();
+				//这里是需要倒着来  最后要到达200 200 这个点
+
+				float fractionNeed = 1 - fraction;
+
+				if (flagX) {
+					float vX = x - targetX;
+					point.x = vX * fractionNeed + targetX;
+				} else {
+					float vX = targetX - x;
+					point.x = x + vX * fraction;
+				}
+
+				if (flagY) {
+					float vY = y - targetY;
+					point.y = vY * fractionNeed + targetY;
+				} else {
+					float vY = targetY - y;
+					point.y = y + vY * fraction;
+				}
+				return point;
+			}
+		});
+		valueAnimator.start();
+		valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+			@Override
+			public void onAnimationUpdate(ValueAnimator animation) {
+				PointF point = (PointF) animation.getAnimatedValue();
+				float vX = point.x;
+				float vY = point.y;
+				//说明vx 最大值就是view原坐标
+				if (flagX) {
+					if (vX <= x && vX >= targetX) {
+						view.setX(vX);
+					}
+				} else {//说明vx 最小值就是view原坐标
+					if (vX >= x && vX <= targetX) {
+						view.setX(vX);
+					}
+				}
+
+				//说明vY 最大值就是view原坐标
+				if (flagY) {
+					if (vY <= y && vY >= targetY) {
+						view.setY(vY);
+					}
+				} else {//说明vx 最小值就是view原坐标
+					if (vY >= y && vY <= targetY) {
+						view.setY(vY);
+					}
+				}
+			}
+		});
+//		view.setLeft(targetView.getLeft());
+//		view.setTop(targetView.getTop());
+//		view.setRight(targetView.getWidth());
+//		view.setBottom(targetView.getHeight());
+	}
 }

+ 0 - 1
app/src/main/java/com/xunao/effectdemo/activity/TestActivity.java

@@ -77,7 +77,6 @@ public class TestActivity extends Activity {
 		public boolean handleMessage(@NonNull Message message) {
 			switch (message.what){
 				case 1:
-					Log.e("MyTag","获取消息"+isResult);
 					if (isResult){
 						isResult = false;
 						setResult();

+ 94 - 0
app/src/main/java/com/xunao/effectdemo/utils/SoundPoolUtil.java

@@ -0,0 +1,94 @@
+package com.xunao.effectdemo.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.media.AudioManager;
+import android.media.SoundPool;
+
+/**
+ * author : 程中强
+ * e-mail : 740479946@qq.com
+ * date : 2022/9/1617:28
+ * desc : 语音播放工具类
+ * version: 1.0
+ */
+public class SoundPoolUtil {
+
+	private volatile static SoundPoolUtil client;
+	private SoundPool mSoundPool;
+	private AudioManager mAudioManager;
+	/*允许同时播放的音频数(为1时会立即结束上一个音频播放当前的音频)*/
+	private static final int MAX_STREAMS = 1;
+	// Stream type.
+	private static final int streamType = AudioManager.STREAM_MUSIC;
+	private int mSoundId;
+	private int mResId;
+	private Context mainContext;
+
+	public static SoundPoolUtil getInstance(Context context) {
+		if (client == null)
+			synchronized (SoundPoolUtil.class) {
+				if (client == null) {
+					client = new SoundPoolUtil(context);
+				}
+			}
+		return client;
+	}
+
+	private SoundPoolUtil(Context context) {
+		this.mainContext = context;
+		mAudioManager = (AudioManager) this.mainContext.getSystemService(Context.AUDIO_SERVICE);
+		((Activity) this.mainContext).setVolumeControlStream(streamType);
+		this.mSoundPool = new SoundPool(MAX_STREAMS, streamType, 0);
+	}
+
+
+	/**
+	 * 播放音频
+	 * @param resId 本地音频资源
+	 */
+	public void playSoundWithRedId(int resId) {
+		this.mResId = resId;
+		this.mSoundId = this.mSoundPool.load(this.mainContext, this.mResId, 1);
+		this.mSoundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
+			@Override
+			public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
+				playSound();
+			}
+		});
+
+	}
+
+	/**
+	 * 播放音频,但是当前有音频这正播放中时不响应该次音频播放
+	 * @param resId 本地音频资源
+	 */
+	public synchronized void playSoundUnfinished(int resId) {
+		if ( isFmActive()) return;
+		this.mResId = resId;
+		this.mSoundId = this.mSoundPool.load(this.mainContext, this.mResId, 1);
+		mSoundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
+			@Override
+			public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
+				playSound();
+			}
+		});
+	}
+
+	/**
+	 * 播放音频文件
+	 */
+	private void playSound() {
+		mSoundPool.play(this.mSoundId, 1.0f, 1.0f, 0, 0, 1f);
+	}
+
+	/**
+	 * 判断当前设备是否正在播放音频
+	 */
+	private boolean isFmActive() {
+		if (mAudioManager == null) {
+			return false;
+		}
+		return mAudioManager.isMusicActive();
+	}
+}

+ 68 - 0
app/src/main/java/com/xunao/effectdemo/view/VideoPreviewPlay.java

@@ -0,0 +1,68 @@
+package com.xunao.effectdemo.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.SeekBar;
+import android.widget.Toast;
+
+import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
+import com.xunao.effectdemo.R;
+import com.xunao.effectdemo.utils.SoundPoolUtil;
+
+/**
+ * author : 程中强
+ * e-mail : 740479946@qq.com
+ * date : 2022/9/1616:21
+ * desc :
+ * version: 1.0
+ */
+public class VideoPreviewPlay extends StandardGSYVideoPlayer {
+
+	private boolean isFinish = false;
+	private SoundPoolUtil soundPoolUtil;
+
+	public void setIsFinish(boolean isFinish){
+		this.isFinish = isFinish;
+	}
+	public VideoPreviewPlay(Context context, Boolean fullFlag) {
+		super(context, fullFlag);
+	}
+
+	public VideoPreviewPlay(Context context) {
+		super(context);
+	}
+
+	public VideoPreviewPlay(Context context, AttributeSet attrs) {
+		super(context, attrs);
+	}
+
+	@Override
+	public int getLayoutId() {
+		return super.getLayoutId();
+	}
+
+	@Override
+	protected void init(Context context) {
+		super.init(context);
+		soundPoolUtil= SoundPoolUtil.getInstance(context);
+		mProgressBar = (SeekBar) findViewById(R.id.progress);
+
+
+		mProgressBar.setOnTouchListener(new OnTouchListener() {
+			@Override
+			public boolean onTouch(View view, MotionEvent motionEvent) {
+				if(isFinish){
+					soundPoolUtil.playSoundWithRedId(R.raw.buyao);
+					Toast toast = Toast.makeText(context,"触摸事件",Toast.LENGTH_SHORT);
+					toast.setGravity(Gravity.TOP,0,0);
+					toast.show();
+					return true;
+				}
+				return false;
+			}
+		});
+	}
+}

+ 19 - 0
app/src/main/res/layout/activity_gsxy_video.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <com.xunao.effectdemo.view.VideoPreviewPlay
+        android:id="@+id/video_play"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_gravity="center"/>
+
+    <Button
+        android:id="@+id/btn_finish"
+        android:text="切换"
+        android:layout_alignParentRight="true"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+</RelativeLayout>

+ 12 - 0
app/src/main/res/layout/activity_ijkplay.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <SurfaceView
+        android:id="@+id/surfaceView"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"></SurfaceView>
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 6 - 0
app/src/main/res/layout/activity_main.xml

@@ -113,6 +113,12 @@
             android:text="单词泛红"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"/>
+
+        <Button
+            android:id="@+id/btn_19"
+            android:text="视频播放"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"/>
     </LinearLayout>
 
 </ScrollView>

BIN
app/src/main/res/raw/buyao.wav


+ 18 - 0
app/src/main/res/values-zh-rTW/strings.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="app_name">动效测试</string>
+    <string name="title_activity_count_down">CountDownActivity</string>
+    <!-- Strings used for fragments for navigation -->
+    <string name="first_fragment_label">First Fragment</string>
+    <string name="second_fragment_label">Second Fragment</string>
+    <string name="next">Next</string>
+    <string name="previous">Previous</string>
+
+    <string name="hello_first_fragment">Hello first fragment</string>
+    <string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
+
+    <string name="start">Start</string>
+    <string name="bt_stop">Stop</string>
+    <string name="action_settings">测评模式设置</string>
+    <string name="action_elastic">测评松紧设置</string>
+</resources>

+ 2 - 0
build.gradle

@@ -6,6 +6,7 @@ buildscript {
         mavenCentral()
         jcenter()
         maven { url 'https://repo1.maven.org/maven2/' }
+        maven { url "https://maven.aliyun.com/repository/public" }
     }
     dependencies {
         classpath "com.android.tools.build:gradle:4.0.0"
@@ -25,6 +26,7 @@ allprojects {
             url "https://jitpack.io"
         }
         maven { url 'https://repo1.maven.org/maven2/' }
+        maven { url "https://maven.aliyun.com/repository/public" }
     }
 }