Search in sources :

Example 1 with ListVideoUtil

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

the class RecyclerView2Activity method initView.

private void initView() {
    linearLayoutManager = new LinearLayoutManager(this);
    listItemRecycler.setLayoutManager(linearLayoutManager);
    resolveData();
    recyclerBaseAdapter = new RecyclerBaseAdapter(this, dataList);
    listItemRecycler.setAdapter(recyclerBaseAdapter);
    listVideoUtil = new ListVideoUtil(this);
    listVideoUtil.setFullViewContainer(videoFullContainer);
    listVideoUtil.setHideStatusBar(true);
    recyclerBaseAdapter.setListVideoUtil(listVideoUtil);
}
Also used : ListVideoUtil(com.shuyu.gsyvideoplayer.utils.ListVideoUtil) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerBaseAdapter(com.example.gsyvideoplayer.adapter.RecyclerBaseAdapter)

Example 2 with ListVideoUtil

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

the class ListVideo2Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // 设置一个exit transition
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        getWindow().setEnterTransition(new Explode());
        getWindow().setExitTransition(new Explode());
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_video2);
    ButterKnife.bind(this);
    listVideoUtil = new ListVideoUtil(this);
    listVideoUtil.setFullViewContainer(videoFullContainer);
    listVideoUtil.setHideStatusBar(true);
    //listVideoUtil.setHideActionBar(true);
    listVideoUtil.setNeedLockFull(true);
    listVideoAdapter = new ListVideoAdapter(this, listVideoUtil);
    listVideoAdapter.setRootView(activityListVideo);
    videoList.setAdapter(listVideoAdapter);
    //listVideoUtil.setShowFullAnimation(true);
    //listVideoUtil.setAutoRotation(true);
    //listVideoUtil.setFullLandFrist(true);
    videoList.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            ListVideo2Activity.this.firstVisibleItem = firstVisibleItem;
            lastVisibleItem = firstVisibleItem + visibleItemCount;
            //大于0说明有播放,//对应的播放列表TAG
            if (listVideoUtil.getPlayPosition() >= 0 && listVideoUtil.getPlayTAG().equals(ListVideoAdapter.TAG)) {
                //当前播放的位置
                int position = listVideoUtil.getPlayPosition();
                //不可视的是时候
                if ((position < firstVisibleItem || position > lastVisibleItem)) {
                    //如果是小窗口就不需要处理
                    if (!listVideoUtil.isSmall()) {
                        //小窗口
                        int size = CommonUtil.dip2px(ListVideo2Activity.this, 150);
                        listVideoUtil.showSmallVideo(new Point(size, size), false, true);
                    }
                } else {
                    if (listVideoUtil.isSmall()) {
                        listVideoUtil.smallVideoToNormal();
                    }
                }
            }
        }
    });
    //小窗口关闭被点击的时候回调处理回复页面
    listVideoUtil.setVideoAllCallBack(new SampleListener() {

        @Override
        public void onPrepared(String url, Object... objects) {
            super.onPrepared(url, objects);
            Debuger.printfLog("Duration " + listVideoUtil.getDuration() + " CurrentPosition " + listVideoUtil.getCurrentPositionWhenPlaying());
        }

        @Override
        public void onQuitSmallWidget(String url, Object... objects) {
            super.onQuitSmallWidget(url, objects);
            //大于0说明有播放,//对应的播放列表TAG
            if (listVideoUtil.getPlayPosition() >= 0 && listVideoUtil.getPlayTAG().equals(ListVideoAdapter.TAG)) {
                //当前播放的位置
                int position = listVideoUtil.getPlayPosition();
                //不可视的是时候
                if ((position < firstVisibleItem || position > lastVisibleItem)) {
                    //释放掉视频
                    listVideoUtil.releaseVideoPlayer();
                    listVideoAdapter.notifyDataSetChanged();
                }
            }
        }
    });
}
Also used : Explode(android.transition.Explode) ListVideoUtil(com.shuyu.gsyvideoplayer.utils.ListVideoUtil) AbsListView(android.widget.AbsListView) Point(android.graphics.Point) SampleListener(com.example.gsyvideoplayer.listener.SampleListener) ListVideoAdapter(com.example.gsyvideoplayer.adapter.ListVideoAdapter) Point(android.graphics.Point)

Aggregations

ListVideoUtil (com.shuyu.gsyvideoplayer.utils.ListVideoUtil)2 Point (android.graphics.Point)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Explode (android.transition.Explode)1 AbsListView (android.widget.AbsListView)1 ListVideoAdapter (com.example.gsyvideoplayer.adapter.ListVideoAdapter)1 RecyclerBaseAdapter (com.example.gsyvideoplayer.adapter.RecyclerBaseAdapter)1 SampleListener (com.example.gsyvideoplayer.listener.SampleListener)1