|
|
@@ -0,0 +1,99 @@
|
|
|
+package com.qingdaofushan.home.activity;
|
|
|
+
|
|
|
+import android.os.Bundle;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
+
|
|
|
+import androidx.appcompat.app.AppCompatActivity;
|
|
|
+
|
|
|
+import com.qingdaofushan.home.R;
|
|
|
+import com.shuyu.gsyvideoplayer.GSYVideoManager;
|
|
|
+import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
|
|
|
+import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 横屏不旋转的 Demo
|
|
|
+ */
|
|
|
+public class SimplePlayer extends AppCompatActivity {
|
|
|
+
|
|
|
+ StandardGSYVideoPlayer videoPlayer;
|
|
|
+
|
|
|
+ OrientationUtils orientationUtils;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_simple_play);
|
|
|
+ init();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void init() {
|
|
|
+ videoPlayer = (StandardGSYVideoPlayer)findViewById(R.id.video_player);
|
|
|
+
|
|
|
+ String source1 = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
|
|
|
+ videoPlayer.setUp(source1, true, "测试视频");
|
|
|
+
|
|
|
+ //增加封面
|
|
|
+// ImageView imageView = new ImageView(this);
|
|
|
+// imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
+// imageView.setImageResource(R.mipmap.xxx1);
|
|
|
+// videoPlayer.setThumbImageView(imageView);
|
|
|
+ //增加title
|
|
|
+ videoPlayer.getTitleTextView().setVisibility(View.VISIBLE);
|
|
|
+ //设置返回键
|
|
|
+ videoPlayer.getBackButton().setVisibility(View.VISIBLE);
|
|
|
+ videoPlayer.getFullscreenButton().setVisibility(View.GONE);
|
|
|
+ //设置旋转
|
|
|
+ orientationUtils = new OrientationUtils(this, videoPlayer);
|
|
|
+ //设置全屏按键功能,这是使用的是选择屏幕,而不是全屏
|
|
|
+ videoPlayer.getFullscreenButton().setOnClickListener(v -> {
|
|
|
+ // ------- !!!如果不需要旋转屏幕,可以不调用!!!-------
|
|
|
+ // 不需要屏幕旋转,还需要设置 setNeedOrientationUtils(false)
|
|
|
+ //orientationUtils.resolveByClick();
|
|
|
+ finish();
|
|
|
+ });
|
|
|
+ //是否可以滑动调整
|
|
|
+ videoPlayer.setIsTouchWiget(true);
|
|
|
+ //设置返回按键功能
|
|
|
+ videoPlayer.getBackButton().setOnClickListener(v -> onBackPressed());
|
|
|
+
|
|
|
+
|
|
|
+ ///不需要屏幕旋转
|
|
|
+ videoPlayer.setNeedOrientationUtils(false);
|
|
|
+
|
|
|
+ videoPlayer.startPlayLogic();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onPause() {
|
|
|
+ super.onPause();
|
|
|
+ videoPlayer.onVideoPause();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ videoPlayer.onVideoResume();
|
|
|
+ }
|
|
|
+
|
|
|
+ @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();
|
|
|
+ }
|
|
|
+}
|