提交 5a560601 编写于 作者: G guoshuyu

#2480

上级 5e5ae182
......@@ -97,6 +97,9 @@ public class DetailPlayer extends AppCompatActivity {
//初始化不打开外部的旋转
orientationUtils.setEnable(false);
/**仅仅横屏旋转,不变直*/
orientationUtils.setOnlyRotateLand(true);
Map<String, String> header = new HashMap<>();
header.put("ee", "33");
header.put("allowCrossProtocolRedirects", "true");
......@@ -104,6 +107,8 @@ public class DetailPlayer extends AppCompatActivity {
gsyVideoOption.setThumbImageView(imageView)
.setIsTouchWiget(true)
.setRotateViewAuto(false)
//仅仅横屏旋转,不变直
.setOnlyRotateLand(true)
.setLockLand(false)
.setAutoFullWithSize(false)
.setShowFullAnimation(false)
......
......@@ -125,6 +125,8 @@ public class GSYVideoOptionBuilder {
// 是否需要覆盖拓展类型
protected String mOverrideExtension;
private boolean mIsOnlyRotateLand = false;
//是否自定义的缓冲文件路径
protected File mCachePath;
......@@ -539,6 +541,13 @@ public class GSYVideoOptionBuilder {
return this;
}
public GSYVideoOptionBuilder setOnlyRotateLand(boolean onlyRotateLand) {
this.mIsOnlyRotateLand = onlyRotateLand;
return this;
}
/**
* 在播放前才真正执行setup
* 目前弃用,请使用正常setup
......@@ -615,6 +624,7 @@ public class GSYVideoOptionBuilder {
gsyVideoPlayer.setOverrideExtension(mOverrideExtension);
gsyVideoPlayer.setAutoFullWithSize(mAutoFullWithSize);
gsyVideoPlayer.setRotateViewAuto(mRotateViewAuto);
gsyVideoPlayer.setOnlyRotateLand(mIsOnlyRotateLand);
gsyVideoPlayer.setLockLand(mLockLand);
gsyVideoPlayer.setSpeed(mSpeed, mSounchTouch);
gsyVideoPlayer.setHideKey(mHideKey);
......
......@@ -34,6 +34,8 @@ public class OrientationUtils {
private boolean mIsPause = false;
private boolean mIsOnlyRotateLand = false;
/**
* @param activity
* @param gsyVideoPlayer
......@@ -44,13 +46,15 @@ public class OrientationUtils {
init();
}
private void init() {
protected void init() {
mOrientationEventListener = new OrientationEventListener(mActivity.getApplicationContext()) {
@Override
public void onOrientationChanged(int rotation) {
boolean autoRotateOn = (Settings.System.getInt(mActivity.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 1);
if (!autoRotateOn && mRotateWithSystem) {
return;
if (!mIsOnlyRotateLand || getIsLand() == LAND_TYPE_NULL) {
return;
}
}
if (mVideoPlayer != null && mVideoPlayer.isVerticalFullByVideoSize()) {
return;
......@@ -70,16 +74,18 @@ public class OrientationUtils {
}
} else {
if (mIsLand > LAND_TYPE_NULL) {
mScreenType = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
if (mVideoPlayer.getFullscreenButton() != null) {
if (mVideoPlayer.isIfCurrentIsFullscreen()) {
mVideoPlayer.getFullscreenButton().setImageResource(mVideoPlayer.getShrinkImageRes());
} else {
mVideoPlayer.getFullscreenButton().setImageResource(mVideoPlayer.getEnlargeImageRes());
if (!mIsOnlyRotateLand) {
mScreenType = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
if (mVideoPlayer.getFullscreenButton() != null) {
if (mVideoPlayer.isIfCurrentIsFullscreen()) {
mVideoPlayer.getFullscreenButton().setImageResource(mVideoPlayer.getShrinkImageRes());
} else {
mVideoPlayer.getFullscreenButton().setImageResource(mVideoPlayer.getEnlargeImageRes());
}
}
mIsLand = LAND_TYPE_NULL;
}
mIsLand = LAND_TYPE_NULL;
mClick = false;
}
}
......@@ -141,7 +147,7 @@ public class OrientationUtils {
mClick = true;
if (mIsLand == LAND_TYPE_NULL) {
int request = mActivity.getRequestedOrientation();
if(request == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
if (request == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
mScreenType = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
} else {
mScreenType = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
......@@ -250,6 +256,17 @@ public class OrientationUtils {
return mRotateWithSystem;
}
public boolean isOnlyRotateLand() {
return mIsOnlyRotateLand;
}
/**
* 旋转时仅处理横屏
*/
public void setOnlyRotateLand(boolean onlyRotateLand) {
this.mIsOnlyRotateLand = onlyRotateLand;
}
/**
* 是否更新系统旋转,false的话,系统禁止旋转也会跟着旋转
*
......
......@@ -81,6 +81,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
//旋转工具类
protected OrientationUtils mOrientationUtils;
private boolean mIsOnlyRotateLand = false;
//全屏返回监听,如果设置了,默认返回无效
protected View.OnClickListener mBackFromFullScreenListener;
protected Handler mInnerHandler = new Handler();
......@@ -313,6 +314,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
mOrientationUtils = new OrientationUtils((Activity) context, gsyVideoPlayer);
mOrientationUtils.setEnable(isRotateViewAuto());
mOrientationUtils.setRotateWithSystem(mRotateWithSystem);
mOrientationUtils.setOnlyRotateLand(mIsOnlyRotateLand);
gsyVideoPlayer.mOrientationUtils = mOrientationUtils;
final boolean isVertical = isVerticalFullByVideoSize();
......@@ -865,6 +867,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
*/
public void setRotateWithSystem(boolean rotateWithSystem) {
this.mRotateWithSystem = rotateWithSystem;
if (mOrientationUtils != null) {
mOrientationUtils.setRotateWithSystem(rotateWithSystem);
}
}
/**
......@@ -971,6 +976,20 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
isNeedAutoAdaptation = needAutoAdaptation;
}
public boolean isOnlyRotateLand() {
return mIsOnlyRotateLand;
}
/**
* 旋转时仅处理横屏
*/
public void setOnlyRotateLand(boolean onlyRotateLand) {
this.mIsOnlyRotateLand = onlyRotateLand;
if (mOrientationUtils != null) {
mOrientationUtils.setOnlyRotateLand(mIsOnlyRotateLand);
}
}
/**
* 检测是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏;
* 并且适配在竖屏横屏时,由于刘海屏或者打孔屏占据空间,导致标题显示被遮盖的问题
......
......@@ -35,7 +35,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//api project(':gsyVideoPlayer-java')
api project(':gsyVideoPlayer-java')
//api project(':gsyVideoPlayer-exo_player2')
//api project(':gsyVideoPlayer-armv5')
//api project(':gsyVideoPlayer-armv7a')
......@@ -48,16 +48,16 @@ dependencies {
//api "com.shuyu:GSYVideoPlayer:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-java:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-java:$gsyVideoVersion"
api "com.shuyu:GSYVideoPlayer-exo2:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-armv5:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-armv7a:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-arm64:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-x64:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-x86:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-armv5:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-armv7a:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-arm64:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-x64:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-x86:$gsyVideoVersion"
//更多配置版so,增加了concat,rtsp,mpeg,crypto
//api "com.shuyu:gsyVideoPlayer-ex_so:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-ex_so:$gsyVideoVersion"
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册