Search in sources :

Example 1 with OrientationUtils

use of com.shuyu.gsyvideoplayer.utils.OrientationUtils in project GSYVideoPlayer by CarGuo.

the class GSYBaseVideoPlayer method resolveFullVideoShow.

/**
     * 全屏
     */
private void resolveFullVideoShow(Context context, final GSYBaseVideoPlayer gsyVideoPlayer, final FrameLayout frameLayout) {
    FrameLayout.LayoutParams lp = (FrameLayout.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);
    mOrientationUtils.setEnable(mRotateViewAuto);
    gsyVideoPlayer.mOrientationUtils = mOrientationUtils;
    if (isShowFullAnimation()) {
        mHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                if (mLockLand && mOrientationUtils.getIsLand() != 1) {
                    mOrientationUtils.resolveByClick();
                }
                gsyVideoPlayer.setVisibility(VISIBLE);
                frameLayout.setVisibility(VISIBLE);
            }
        }, 300);
    } else {
        if (mLockLand) {
            mOrientationUtils.resolveByClick();
        }
        gsyVideoPlayer.setVisibility(VISIBLE);
        frameLayout.setVisibility(VISIBLE);
    }
    if (mVideoAllCallBack != null) {
        Debuger.printfError("onEnterFullscreen");
        mVideoAllCallBack.onEnterFullscreen(mUrl, mObjects);
    }
    mIfCurrentIsFullscreen = true;
}
Also used : FrameLayout(android.widget.FrameLayout) OrientationUtils(com.shuyu.gsyvideoplayer.utils.OrientationUtils) Activity(android.app.Activity)

Example 2 with OrientationUtils

use of com.shuyu.gsyvideoplayer.utils.OrientationUtils in project GSYVideoPlayer by CarGuo.

the class DanmkuVideoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_danmaku_layout);
    ButterKnife.bind(this);
    //使用自定义的全屏切换图片,!!!注意xml布局中也需要设置为一样的
    //必须在setUp之前设置
    danmakuVideoPlayer.setShrinkImageRes(R.drawable.custom_shrink);
    danmakuVideoPlayer.setEnlargeImageRes(R.drawable.custom_enlarge);
    String url = "http://baobab.wdjcdn.com/14564977406580.mp4";
    //String url = "https://res.exexm.com/cw_145225549855002";
    danmakuVideoPlayer.setUp(url, true, null, "测试视频");
    //增加封面
    ImageView imageView = new ImageView(this);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setImageResource(R.mipmap.xxx1);
    danmakuVideoPlayer.setThumbImageView(imageView);
    resolveNormalVideoUI();
    //外部辅助的旋转,帮助全屏
    orientationUtils = new OrientationUtils(this, danmakuVideoPlayer);
    //初始化不打开外部的旋转
    orientationUtils.setEnable(false);
    danmakuVideoPlayer.setIsTouchWiget(true);
    //关闭自动旋转
    danmakuVideoPlayer.setRotateViewAuto(false);
    danmakuVideoPlayer.setLockLand(false);
    danmakuVideoPlayer.setShowFullAnimation(false);
    danmakuVideoPlayer.setNeedLockFull(true);
    //detailPlayer.setOpenPreView(true);
    danmakuVideoPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //直接横屏
            orientationUtils.resolveByClick();
            //第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar
            danmakuVideoPlayer.startWindowFullscreen(DanmkuVideoActivity.this, true, true);
        }
    });
    danmakuVideoPlayer.setStandardVideoAllCallBack(new SampleListener() {

        @Override
        public void onPrepared(String url, Object... objects) {
            super.onPrepared(url, objects);
            //开始播放了才能旋转和全屏
            orientationUtils.setEnable(true);
            isPlay = true;
        }

        @Override
        public void onAutoComplete(String url, Object... objects) {
            super.onAutoComplete(url, objects);
        }

        @Override
        public void onClickStartError(String url, Object... objects) {
            super.onClickStartError(url, objects);
        }

        @Override
        public void onQuitFullscreen(String url, Object... objects) {
            super.onQuitFullscreen(url, objects);
            if (orientationUtils != null) {
                orientationUtils.backToProtVideo();
            }
        }
    });
    danmakuVideoPlayer.setLockClickListener(new LockClickListener() {

        @Override
        public void onClick(View view, boolean lock) {
            if (orientationUtils != null) {
                //配合下方的onConfigurationChanged
                orientationUtils.setEnable(!lock);
            }
        }
    });
}
Also used : OrientationUtils(com.shuyu.gsyvideoplayer.utils.OrientationUtils) ImageView(android.widget.ImageView) SampleListener(com.example.gsyvideoplayer.listener.SampleListener) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) LockClickListener(com.shuyu.gsyvideoplayer.listener.LockClickListener)

Example 3 with OrientationUtils

use of com.shuyu.gsyvideoplayer.utils.OrientationUtils in project GSYVideoPlayer by CarGuo.

the class DetailListPlayer method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_deatil_list_player);
    ButterKnife.bind(this);
    //String url = "http://baobab.wd jcdn.com/14564977406580.mp4";
    List<GSYVideoModel> urls = new ArrayList<>();
    urls.add(new GSYVideoModel("http://baobab.wdjcdn.com/14564977406580.mp4", "标题1"));
    urls.add(new GSYVideoModel("http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4", "标题2"));
    urls.add(new GSYVideoModel("http://baobab.wdjcdn.com/14564977406580.mp4", "标题3"));
    urls.add(new GSYVideoModel("http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4", "标题4"));
    detailPlayer.setUp(urls, true, 0, "");
    //增加封面
    ImageView imageView = new ImageView(this);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setImageResource(R.mipmap.xxx1);
    detailPlayer.setThumbImageView(imageView);
    resolveNormalVideoUI();
    //外部辅助的旋转,帮助全屏
    orientationUtils = new OrientationUtils(this, detailPlayer);
    //初始化不打开外部的旋转
    orientationUtils.setEnable(false);
    detailPlayer.setIsTouchWiget(true);
    //关闭自动旋转
    detailPlayer.setRotateViewAuto(false);
    detailPlayer.setLockLand(false);
    detailPlayer.setShowFullAnimation(false);
    detailPlayer.setNeedLockFull(true);
    detailPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //直接横屏
            orientationUtils.resolveByClick();
            //第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar
            detailPlayer.startWindowFullscreen(DetailListPlayer.this, true, true);
        }
    });
    detailPlayer.setStandardVideoAllCallBack(new SampleListener() {

        @Override
        public void onPrepared(String url, Object... objects) {
            super.onPrepared(url, objects);
            //开始播放了才能旋转和全屏
            orientationUtils.setEnable(true);
            isPlay = true;
        }

        @Override
        public void onAutoComplete(String url, Object... objects) {
            super.onAutoComplete(url, objects);
        }

        @Override
        public void onClickStartError(String url, Object... objects) {
            super.onClickStartError(url, objects);
        }

        @Override
        public void onQuitFullscreen(String url, Object... objects) {
            super.onQuitFullscreen(url, objects);
            if (orientationUtils != null) {
                orientationUtils.backToProtVideo();
            }
        }
    });
    detailPlayer.setLockClickListener(new LockClickListener() {

        @Override
        public void onClick(View view, boolean lock) {
            if (orientationUtils != null) {
                //配合下方的onConfigurationChanged
                orientationUtils.setEnable(!lock);
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) SampleListener(com.example.gsyvideoplayer.listener.SampleListener) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) LockClickListener(com.shuyu.gsyvideoplayer.listener.LockClickListener) GSYVideoModel(com.shuyu.gsyvideoplayer.model.GSYVideoModel) OrientationUtils(com.shuyu.gsyvideoplayer.utils.OrientationUtils) ImageView(android.widget.ImageView)

Example 4 with OrientationUtils

use of com.shuyu.gsyvideoplayer.utils.OrientationUtils in project GSYVideoPlayer by CarGuo.

the class WebDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_detail);
    ButterKnife.bind(this);
    String url = "http://baobab.wdjcdn.com/14564977406580.mp4";
    //String url = "https://d131x7vzzf85jg.cloudfront.net/upload/documents/paper/b2/61/00/00/20160420_115018_b544.mp4";
    webPlayer.setUp(url, true, null, "测试视频");
    //增加封面
    ImageView imageView = new ImageView(this);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setImageResource(R.mipmap.xxx1);
    webPlayer.setThumbImageView(imageView);
    resolveNormalVideoUI();
    //外部辅助的旋转,帮助全屏
    orientationUtils = new OrientationUtils(this, webPlayer);
    //初始化不打开外部的旋转
    orientationUtils.setEnable(false);
    webPlayer.setIsTouchWiget(true);
    //关闭自动旋转
    webPlayer.setRotateViewAuto(false);
    webPlayer.setLockLand(false);
    webPlayer.setShowFullAnimation(false);
    webPlayer.setNeedLockFull(true);
    //detailPlayer.setOpenPreView(true);
    webPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //直接横屏
            orientationUtils.resolveByClick();
            //第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar
            webPlayer.startWindowFullscreen(WebDetailActivity.this, true, true);
        }
    });
    webPlayer.setStandardVideoAllCallBack(new SampleListener() {

        @Override
        public void onPrepared(String url, Object... objects) {
            super.onPrepared(url, objects);
            //开始播放了才能旋转和全屏
            orientationUtils.setEnable(true);
            isPlay = true;
        }

        @Override
        public void onAutoComplete(String url, Object... objects) {
            super.onAutoComplete(url, objects);
        }

        @Override
        public void onClickStartError(String url, Object... objects) {
            super.onClickStartError(url, objects);
        }

        @Override
        public void onQuitFullscreen(String url, Object... objects) {
            super.onQuitFullscreen(url, objects);
            if (orientationUtils != null) {
                orientationUtils.backToProtVideo();
            }
        }
    });
    webPlayer.setLockClickListener(new LockClickListener() {

        @Override
        public void onClick(View view, boolean lock) {
            if (orientationUtils != null) {
                //配合下方的onConfigurationChanged
                orientationUtils.setEnable(!lock);
            }
        }
    });
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    webView.loadUrl("https://www.baidu.com");
    webTopLayout.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {

        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (!webPlayer.isIfCurrentIsFullscreen() && scrollY >= 0 && isPlay) {
                if (scrollY > webPlayer.getHeight()) {
                    //如果是小窗口就不需要处理
                    if (!isSamll) {
                        isSamll = true;
                        int size = CommonUtil.dip2px(WebDetailActivity.this, 150);
                        webPlayer.showSmallVideo(new Point(size, size), true, true);
                        orientationUtils.setEnable(false);
                    }
                } else {
                    if (isSamll) {
                        isSamll = false;
                        orientationUtils.setEnable(true);
                        //必须
                        webTopLayoutVideo.postDelayed(new Runnable() {

                            @Override
                            public void run() {
                                webPlayer.hideSmallVideo();
                            }
                        }, 50);
                    }
                }
                webTopLayoutVideo.setTranslationY((scrollY <= webTopLayoutVideo.getHeight()) ? -scrollY : -webTopLayoutVideo.getHeight());
            }
        }
    });
}
Also used : Point(android.graphics.Point) SampleListener(com.example.gsyvideoplayer.listener.SampleListener) ImageView(android.widget.ImageView) BindView(butterknife.BindView) ScrollWebView(com.example.gsyvideoplayer.view.ScrollWebView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) LockClickListener(com.shuyu.gsyvideoplayer.listener.LockClickListener) Point(android.graphics.Point) WebSettings(android.webkit.WebSettings) OrientationUtils(com.shuyu.gsyvideoplayer.utils.OrientationUtils) ImageView(android.widget.ImageView) NestedScrollView(android.support.v4.widget.NestedScrollView)

Example 5 with OrientationUtils

use of com.shuyu.gsyvideoplayer.utils.OrientationUtils in project GSYVideoPlayer by CarGuo.

the class DetailPlayer method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail_player);
    ButterKnife.bind(this);
    String url = "http://baobab.wdjcdn.com/14564977406580.mp4";
    //String url = "https://res.exexm.com/cw_145225549855002";
    detailPlayer.setUp(url, true, null, "测试视频");
    /*VideoOptionModel videoOptionModel =
                new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 50);
        List<VideoOptionModel> list = new ArrayList<>();
        list.add(videoOptionModel);
        GSYVideoManager.instance().setOptionModelList(list);*/
    //增加封面
    ImageView imageView = new ImageView(this);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setImageResource(R.mipmap.xxx1);
    detailPlayer.setThumbImageView(imageView);
    resolveNormalVideoUI();
    //外部辅助的旋转,帮助全屏
    orientationUtils = new OrientationUtils(this, detailPlayer);
    //初始化不打开外部的旋转
    orientationUtils.setEnable(false);
    detailPlayer.setIsTouchWiget(true);
    //关闭自动旋转
    detailPlayer.setRotateViewAuto(false);
    detailPlayer.setLockLand(false);
    detailPlayer.setShowFullAnimation(false);
    detailPlayer.setNeedLockFull(true);
    detailPlayer.setOpenPreView(true);
    detailPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //直接横屏
            orientationUtils.resolveByClick();
            //第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar
            detailPlayer.startWindowFullscreen(DetailPlayer.this, true, true);
        }
    });
    detailPlayer.setStandardVideoAllCallBack(new SampleListener() {

        @Override
        public void onPrepared(String url, Object... objects) {
            super.onPrepared(url, objects);
            //开始播放了才能旋转和全屏
            orientationUtils.setEnable(true);
            isPlay = true;
        }

        @Override
        public void onAutoComplete(String url, Object... objects) {
            super.onAutoComplete(url, objects);
        }

        @Override
        public void onClickStartError(String url, Object... objects) {
            super.onClickStartError(url, objects);
        }

        @Override
        public void onQuitFullscreen(String url, Object... objects) {
            super.onQuitFullscreen(url, objects);
            if (orientationUtils != null) {
                orientationUtils.backToProtVideo();
            }
        }
    });
    detailPlayer.setLockClickListener(new LockClickListener() {

        @Override
        public void onClick(View view, boolean lock) {
            if (orientationUtils != null) {
                //配合下方的onConfigurationChanged
                orientationUtils.setEnable(!lock);
            }
        }
    });
}
Also used : OrientationUtils(com.shuyu.gsyvideoplayer.utils.OrientationUtils) ImageView(android.widget.ImageView) SampleListener(com.example.gsyvideoplayer.listener.SampleListener) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) LockClickListener(com.shuyu.gsyvideoplayer.listener.LockClickListener)

Aggregations

OrientationUtils (com.shuyu.gsyvideoplayer.utils.OrientationUtils)6 View (android.view.View)5 ImageView (android.widget.ImageView)5 BindView (butterknife.BindView)5 NestedScrollView (android.support.v4.widget.NestedScrollView)4 SampleListener (com.example.gsyvideoplayer.listener.SampleListener)4 LockClickListener (com.shuyu.gsyvideoplayer.listener.LockClickListener)4 ArrayList (java.util.ArrayList)2 Activity (android.app.Activity)1 Point (android.graphics.Point)1 WebSettings (android.webkit.WebSettings)1 FrameLayout (android.widget.FrameLayout)1 SwitchVideoModel (com.example.gsyvideoplayer.model.SwitchVideoModel)1 ScrollWebView (com.example.gsyvideoplayer.view.ScrollWebView)1 GSYVideoModel (com.shuyu.gsyvideoplayer.model.GSYVideoModel)1