com.shuyu.gsyvideoplayer.utils.OrientationUtils Java Examples

The following examples show how to use com.shuyu.gsyvideoplayer.utils.OrientationUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GSYBaseActivityDetail.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 选择普通模式
 */
public void initVideo() {
    //外部辅助的旋转,帮助全屏
    orientationUtils = new OrientationUtils(this, getGSYVideoPlayer(), getOrientationOption());
    //初始化不打开外部的旋转
    orientationUtils.setEnable(false);
    if (getGSYVideoPlayer().getFullscreenButton() != null) {
        getGSYVideoPlayer().getFullscreenButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showFull();
                clickForFullScreen();
            }
        });
    }
}
 
Example #2
Source File: GSYBaseADActivityDetail.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public void initVideo() {
    super.initVideo();
    //外部辅助的旋转,帮助全屏
    mADOrientationUtils = new OrientationUtils(this, getGSYADVideoPlayer(), getOrientationOption());
    //初始化不打开外部的旋转
    mADOrientationUtils.setEnable(false);
    if (getGSYADVideoPlayer().getFullscreenButton() != null) {
        getGSYADVideoPlayer().getFullscreenButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //直接横屏
                showADFull();
                clickForFullScreen();
            }
        });
    }
}
 
Example #3
Source File: GSYBaseVideoPlayer.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 旋转处理
 *
 * @param activity         页面
 * @param newConfig        配置
 * @param orientationUtils 旋转工具类
 * @param hideActionBar    是否隐藏actionbar
 * @param hideStatusBar    是否隐藏statusbar
 */
public void onConfigurationChanged(Activity activity, Configuration newConfig, OrientationUtils orientationUtils, boolean hideActionBar, boolean hideStatusBar) {
    super.onConfigurationChanged(newConfig);
    //如果旋转了就全屏
    if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_USER) {
        if (!isIfCurrentIsFullscreen()) {
            startWindowFullscreen(activity, hideActionBar, hideStatusBar);
        }
    } else {
        //新版本isIfCurrentIsFullscreen的标志位内部提前设置了,所以不会和手动点击冲突
        if (isIfCurrentIsFullscreen() && !isVerticalFullByVideoSize()) {
            backFromFull(activity);
        }
        if (orientationUtils != null) {
            orientationUtils.setEnable(true);
        }
    }

}
 
Example #4
Source File: ListNormalAdapter.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
private void initOrientationUtils(StandardGSYVideoPlayer standardGSYVideoPlayer, boolean full) {
    orientationUtils = new OrientationUtils((Activity) context, standardGSYVideoPlayer);
    //是否需要跟随系统旋转设置
    //orientationUtils.setRotateWithSystem(false);
    orientationUtils.setEnable(false);
    orientationUtils.setIsLand((full) ? 1 : 0);
}
 
Example #5
Source File: VideoFragment.java    From tysq-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void initView(View view) {

    String proxyUrl = JerryProxy.getInstance().getProxyUrl(mUrl);
    videoPlayer.setUp(proxyUrl, false, mTitle);

    //增加封面
    ImageView imageView = new ImageView(getContext());
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

    TyUtils.getGlideRequest(
            this,
            getContext(),
            mCover,
            null,
            imageView);

    videoPlayer.setThumbImageView(imageView);

    //增加title
    videoPlayer.getTitleTextView().setVisibility(View.VISIBLE);
    //设置返回键
    videoPlayer.getBackButton().setVisibility(View.VISIBLE);

    //设置旋转
    orientationUtils = new OrientationUtils(getActivity(), videoPlayer);

    //设置全屏按键功能,这是使用的是选择屏幕,而不是全屏
    videoPlayer.getFullscreenButton().setOnClickListener(v -> orientationUtils.resolveByClick());

    //是否可以滑动调整
    videoPlayer.setIsTouchWiget(true);

    //设置返回按键功能
    videoPlayer.getBackButton().setOnClickListener(v -> {
        if (getActivity() == null) {
            return;
        }
        getActivity().finish();
    });
    videoPlayer.startPlayLogic();
}
 
Example #6
Source File: ListNormalAdapter.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
public OrientationUtils getOrientationUtils() {
    return orientationUtils;
}
 
Example #7
Source File: GSYBaseVideoPlayer.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
/**
 * 全屏
 */
protected void resolveFullVideoShow(Context context, final GSYBaseVideoPlayer gsyVideoPlayer, final FrameLayout frameLayout) {
    LayoutParams lp = (LayoutParams) gsyVideoPlayer.getLayoutParams();
    lp.setMargins(0, 0, 0, 0);
    lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
    lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
    lp.gravity = Gravity.CENTER;
    gsyVideoPlayer.setLayoutParams(lp);
    gsyVideoPlayer.setIfCurrentIsFullscreen(true);
    mOrientationUtils = new OrientationUtils((Activity) context, gsyVideoPlayer, getOrientationOption());
    mOrientationUtils.setEnable(isRotateViewAuto());
    mOrientationUtils.setRotateWithSystem(mRotateWithSystem);
    mOrientationUtils.setOnlyRotateLand(mIsOnlyRotateLand);
    gsyVideoPlayer.mOrientationUtils = mOrientationUtils;

    final boolean isVertical = isVerticalFullByVideoSize();
    final boolean isLockLand = isLockLandByAutoFullSize();

    if (isShowFullAnimation()) {
        mInnerHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                //autoFull模式下,非横屏视频视频不横屏,并且不自动旋转
                if (!isVertical && isLockLand && mOrientationUtils != null && mOrientationUtils.getIsLand() != 1) {
                    mOrientationUtils.resolveByClick();
                }
                gsyVideoPlayer.setVisibility(VISIBLE);
                frameLayout.setVisibility(VISIBLE);
            }
        }, 300);
    } else {
        if (!isVertical && isLockLand && mOrientationUtils != null) {
            mOrientationUtils.resolveByClick();
        }
        gsyVideoPlayer.setVisibility(VISIBLE);
        frameLayout.setVisibility(VISIBLE);
    }


    if (mVideoAllCallBack != null) {
        Debuger.printfError("onEnterFullscreen");
        mVideoAllCallBack.onEnterFullscreen(mOriginUrl, mTitle, gsyVideoPlayer);
    }
    mIfCurrentIsFullscreen = true;

    checkoutState();

    checkAutoFullWithSizeAndAdaptation(gsyVideoPlayer);
}
 
Example #8
Source File: GSYBaseVideoPlayer.java    From GSYVideoPlayer with Apache License 2.0 2 votes vote down vote up
/**
 * 旋转处理
 *
 * @param activity         页面
 * @param newConfig        配置
 * @param orientationUtils 旋转工具类
 */
public void onConfigurationChanged(Activity activity, Configuration newConfig, OrientationUtils orientationUtils) {
    onConfigurationChanged(activity, newConfig, orientationUtils, true, true);

}