提交 bfc96417 编写于 作者: S shuyu

add AutoFullWithSize support

上级 0cf9e057
...@@ -79,8 +79,9 @@ public class ListNormalAdapter extends BaseAdapter { ...@@ -79,8 +79,9 @@ public class ListNormalAdapter extends BaseAdapter {
//final String url = "https://res.exexm.com/cw_145225549855002"; //final String url = "https://res.exexm.com/cw_145225549855002";
final String url = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"; final String urlH = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
//final String url = "http://7xse1z.com1.z0.glb.clouddn.com/1491813192"; final String urlV = "http://7xse1z.com1.z0.glb.clouddn.com/1491813192";
final String url = (position % 2 == 0) ? urlH : urlV;
//final String url = "http://111.198.24.133:83/yyy_login_server/pic/YB059284/97778276040859/1.mp4"; //final String url = "http://111.198.24.133:83/yyy_login_server/pic/YB059284/97778276040859/1.mp4";
...@@ -95,7 +96,7 @@ public class ListNormalAdapter extends BaseAdapter { ...@@ -95,7 +96,7 @@ public class ListNormalAdapter extends BaseAdapter {
//默认缓存路径 //默认缓存路径
//使用lazy的set可以避免滑动卡的情况存在 //使用lazy的set可以避免滑动卡的情况存在
holder.gsyVideoPlayer.setUpLazy(url, true, null, null, "这是title"); holder.gsyVideoPlayer.setUpLazy(url, false, null, null, "这是title");
//holder.gsyVideoPlayer.setNeedShowWifiTip(false); //holder.gsyVideoPlayer.setNeedShowWifiTip(false);
...@@ -247,7 +248,7 @@ public class ListNormalAdapter extends BaseAdapter { ...@@ -247,7 +248,7 @@ public class ListNormalAdapter extends BaseAdapter {
* @return 返回true为支持列表重力全屏 * @return 返回true为支持列表重力全屏
*/ */
public boolean getListNeedAutoLand() { public boolean getListNeedAutoLand() {
return true; return false;
} }
private void initOrientationUtils(StandardGSYVideoPlayer standardGSYVideoPlayer, boolean full) { private void initOrientationUtils(StandardGSYVideoPlayer standardGSYVideoPlayer, boolean full) {
......
...@@ -21,9 +21,12 @@ public class OrientationUtils { ...@@ -21,9 +21,12 @@ public class OrientationUtils {
private int screenType = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; private int screenType = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
private int mIsLand; private int mIsLand;
private boolean mClick, mClickLand, mClickPort; private boolean mClick = false;
private boolean mClickLand = false;
private boolean mClickPort;
private boolean mEnable = true; private boolean mEnable = true;
private boolean mRotateWithSystem = true; //是否跟随系统 //是否跟随系统
private boolean mRotateWithSystem = true;
/** /**
* @param activity * @param activity
...@@ -42,7 +45,7 @@ public class OrientationUtils { ...@@ -42,7 +45,7 @@ public class OrientationUtils {
boolean autoRotateOn = (Settings.System.getInt(activity.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 1); boolean autoRotateOn = (Settings.System.getInt(activity.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 1);
if (!autoRotateOn && mRotateWithSystem) { if (!autoRotateOn && mRotateWithSystem) {
//if (mIsLand == 0) { //if (mIsLand == 0) {
return; return;
//} //}
} }
// 设置竖屏 // 设置竖屏
...@@ -231,6 +234,7 @@ public class OrientationUtils { ...@@ -231,6 +234,7 @@ public class OrientationUtils {
/** /**
* 是否更新系统旋转,false的话,系统禁止旋转也会跟着旋转 * 是否更新系统旋转,false的话,系统禁止旋转也会跟着旋转
*
* @param rotateWithSystem 默认true * @param rotateWithSystem 默认true
*/ */
public void setRotateWithSystem(boolean rotateWithSystem) { public void setRotateWithSystem(boolean rotateWithSystem) {
......
...@@ -22,6 +22,8 @@ import com.transitionseverywhere.TransitionManager; ...@@ -22,6 +22,8 @@ import com.transitionseverywhere.TransitionManager;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import static com.shuyu.gsyvideoplayer.utils.CommonUtil.getActionBarHeight; import static com.shuyu.gsyvideoplayer.utils.CommonUtil.getActionBarHeight;
import static com.shuyu.gsyvideoplayer.utils.CommonUtil.getStatusBarHeight; import static com.shuyu.gsyvideoplayer.utils.CommonUtil.getStatusBarHeight;
import static com.shuyu.gsyvideoplayer.utils.CommonUtil.hideNavKey; import static com.shuyu.gsyvideoplayer.utils.CommonUtil.hideNavKey;
...@@ -63,6 +65,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView { ...@@ -63,6 +65,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
//当前全屏是否锁定全屏 //当前全屏是否锁定全屏
protected boolean mLockLand = false; protected boolean mLockLand = false;
//是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
protected boolean mAutoFullWithSize = false;
//小窗口关闭按键 //小窗口关闭按键
protected View mSmallClose; protected View mSmallClose;
...@@ -139,13 +144,28 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView { ...@@ -139,13 +144,28 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
super.lockTouchLogic(); super.lockTouchLogic();
if (mLockCurScreen) { if (mLockCurScreen) {
if (mOrientationUtils != null) if (mOrientationUtils != null)
mOrientationUtils.setEnable(mRotateViewAuto); mOrientationUtils.setEnable(isRotateViewAuto());
} else { } else {
if (mOrientationUtils != null) if (mOrientationUtils != null)
mOrientationUtils.setEnable(false); mOrientationUtils.setEnable(false);
} }
} }
@Override
public void onPrepared() {
super.onPrepared();
//确保开启竖屏检测的时候正常全屏
checkAutoFullSizeWhenFull();
}
@Override
public void onInfo(int what, int extra) {
super.onInfo(what, extra);
if (what == IMediaPlayer.MEDIA_INFO_VIDEO_ROTATION_CHANGED) {
checkAutoFullSizeWhenFull();
}
}
private ViewGroup getViewGroup() { private ViewGroup getViewGroup() {
return (ViewGroup) (CommonUtil.scanForActivity(getContext())).findViewById(Window.ID_ANDROID_CONTENT); return (ViewGroup) (CommonUtil.scanForActivity(getContext())).findViewById(Window.ID_ANDROID_CONTENT);
...@@ -216,6 +236,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView { ...@@ -216,6 +236,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
to.mVideoAllCallBack = from.mVideoAllCallBack; to.mVideoAllCallBack = from.mVideoAllCallBack;
to.mActionBar = from.mActionBar; to.mActionBar = from.mActionBar;
to.mStatusBar = from.mStatusBar; to.mStatusBar = from.mStatusBar;
to.mAutoFullWithSize = from.mAutoFullWithSize;
if (from.mSetUpLazy) { if (from.mSetUpLazy) {
to.setUpLazy(from.mOriginUrl, from.mCache, from.mCachePath, from.mMapHeadData, from.mTitle); to.setUpLazy(from.mOriginUrl, from.mCache, from.mCachePath, from.mMapHeadData, from.mTitle);
to.mUrl = from.mUrl; to.mUrl = from.mUrl;
...@@ -278,15 +299,20 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView { ...@@ -278,15 +299,20 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
gsyVideoPlayer.setLayoutParams(lp); gsyVideoPlayer.setLayoutParams(lp);
gsyVideoPlayer.setIfCurrentIsFullscreen(true); gsyVideoPlayer.setIfCurrentIsFullscreen(true);
mOrientationUtils = new OrientationUtils((Activity) context, gsyVideoPlayer); mOrientationUtils = new OrientationUtils((Activity) context, gsyVideoPlayer);
mOrientationUtils.setEnable(mRotateViewAuto); mOrientationUtils.setEnable(isRotateViewAuto());
mOrientationUtils.setRotateWithSystem(mRotateWithSystem); mOrientationUtils.setRotateWithSystem(mRotateWithSystem);
gsyVideoPlayer.mOrientationUtils = mOrientationUtils; gsyVideoPlayer.mOrientationUtils = mOrientationUtils;
final boolean isVertical = isVerticalVideoFull();
final boolean isLockLand = isLockLandByAutoFullSize();
if (isShowFullAnimation()) { if (isShowFullAnimation()) {
postDelayed(new Runnable() { postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
if (mLockLand && mOrientationUtils.getIsLand() != 1) { Debuger.printfLog("GSYVideoBase resolveFullVideoShow isVerticalVideoFull " + isVertical);
//autoFull模式下,非横屏视频视频不横屏,并且不自动旋转
if (!isVertical && isLockLand && mOrientationUtils.getIsLand() != 1) {
mOrientationUtils.resolveByClick(); mOrientationUtils.resolveByClick();
} }
gsyVideoPlayer.setVisibility(VISIBLE); gsyVideoPlayer.setVisibility(VISIBLE);
...@@ -294,7 +320,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView { ...@@ -294,7 +320,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
} }
}, 300); }, 300);
} else { } else {
if (mLockLand) { if (!isVertical && isLockLand) {
mOrientationUtils.resolveByClick(); mOrientationUtils.resolveByClick();
} }
gsyVideoPlayer.setVisibility(VISIBLE); gsyVideoPlayer.setVisibility(VISIBLE);
...@@ -441,6 +467,58 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView { ...@@ -441,6 +467,58 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
postDelayed(mCheckoutTask, 500); postDelayed(mCheckoutTask, 500);
} }
/**
* 是否需要使用竖屏全屏
*/
protected boolean isVerticalVideoFull() {
return isVerticalVideo() && isAutoFullWithSize();
}
/**
* 是否竖屏模式的竖屏
*/
protected boolean isVerticalVideo() {
boolean isVertical = false;
int videoHeight = getCurrentVideoHeight();
int videoWidth = getCurrentVideoWidth();
Debuger.printfLog("GSYVideoBase isVerticalVideo videoHeight " + videoHeight + " videoWidth " + videoWidth);
Debuger.printfLog("GSYVideoBase isVerticalVideo mRotate " + mRotate);
if (videoHeight > 0 && videoWidth > 0) {
if (mRotate == 90 || mRotate == 270) {
isVertical = videoWidth > videoHeight;
} else {
isVertical = videoHeight > videoWidth;
}
}
return isVertical;
}
/**
* 是否根据autoFullSize调整lockLand
*/
protected boolean isLockLandByAutoFullSize() {
boolean isLockLand = mLockLand;
if (isAutoFullWithSize()) {
isLockLand = true;
}
return isLockLand;
}
/**
* 确保开启竖屏检测的时候正常全屏
*/
protected void checkAutoFullSizeWhenFull() {
if (mIfCurrentIsFullscreen) {
//确保开启竖屏检测的时候正常全屏
boolean isV = isVerticalVideoFull();
Debuger.printfLog("GSYVideoBase onPrepared isVerticalVideoFull " + isV);
if (isV) {
if (mOrientationUtils != null)
mOrientationUtils.backToProtVideo();
}
}
}
protected abstract int getFullId(); protected abstract int getFullId();
protected abstract int getSmallId(); protected abstract int getSmallId();
...@@ -722,6 +800,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView { ...@@ -722,6 +800,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
} }
public boolean isRotateViewAuto() { public boolean isRotateViewAuto() {
if (mAutoFullWithSize) {
return false;
}
return mRotateViewAuto; return mRotateViewAuto;
} }
...@@ -836,4 +917,16 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView { ...@@ -836,4 +917,16 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
public void setSaveBeforeFullSystemUiVisibility(int systemUiVisibility) { public void setSaveBeforeFullSystemUiVisibility(int systemUiVisibility) {
this.mSystemUiVisibility = systemUiVisibility; this.mSystemUiVisibility = systemUiVisibility;
} }
public boolean isAutoFullWithSize() {
return mAutoFullWithSize;
}
/**
* 是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
* @param autoFullWithSize 默认false
*/
public void setAutoFullWithSize(boolean autoFullWithSize) {
this.mAutoFullWithSize = autoFullWithSize;
}
} }
...@@ -1133,4 +1133,18 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe ...@@ -1133,4 +1133,18 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
public void setReleaseWhenLossAudio(boolean releaseWhenLossAudio) { public void setReleaseWhenLossAudio(boolean releaseWhenLossAudio) {
this.mReleaseWhenLossAudio = releaseWhenLossAudio; this.mReleaseWhenLossAudio = releaseWhenLossAudio;
} }
public Map<String, String> getMapHeadData() {
return mMapHeadData;
}
/**
* 单独设置mapHeader
* @param headData
*/
public void setMapHeadData(Map<String, String> headData) {
if (headData != null) {
this.mMapHeadData = headData;
}
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册