admin
2020-10-15 cd89367a01870afb5c1e818895abb03ffea42d88
BuWanVideo/src/com/weikou/beibeivideo/ui/media/VideoDetailActivity2.java
@@ -62,6 +62,7 @@
import com.weikou.beibeivideo.ui.BaseActivity;
import com.weikou.beibeivideo.ui.ad.PlayVideoPreADFragment;
import com.weikou.beibeivideo.ui.common.ShareActivity;
import com.weikou.beibeivideo.ui.mine.FXBrowserActivity;
import com.weikou.beibeivideo.ui.video.FunshionPlayerFragment;
import com.weikou.beibeivideo.ui.video.VideoPlayerActivity;
import com.weikou.beibeivideo.util.BeibeiConstant;
@@ -132,6 +133,8 @@
        fl_video_play_background = findViewById(R.id.fl_video_play_background);
        iv_background = findViewById(R.id.iv_video_play_background);
        fl_ad = findViewById(R.id.fl_ad);
        initPlayer();
    }
    @Override
@@ -266,9 +269,6 @@
                    .commitAllowingStateLoss();
        }
        iNet();
        if (fl_ad != null)
            fl_ad.setVisibility(View.VISIBLE);
    }
@@ -371,6 +371,7 @@
                            VideoPlayerActivity.class);
                    intent.putExtra("url", playUrl.getUrl());
                    startActivity(intent);
                    initPlayer();
                } else if (playUrl.getPlayType() == 2) {
                    iv_select_play.setVisibility(View.GONE);
                    iv_background.setClickable(false);
@@ -387,9 +388,11 @@
                    // EventBus.getDefault().post(playUrl);
                    Toast.makeText(VideoDetailActivity2.this, "影片加载中...",
                            Toast.LENGTH_LONG).show();
                    initPlayer();
                }
                saveWatchHistory("爱奇艺");
            }
        } else if (playUrl.getResource().getName().contains("风行")) {
            if (playUrl.getPlayType() == 0) {
@@ -397,25 +400,27 @@
                        Toast.LENGTH_LONG).show();
                return;
            } else if (playUrl.getPlayType() == 1) {
//                Intent intent = new Intent(VideoDetailActivity2.this,
//                        FXBrowserActivity.class);
//                intent.putExtra("url", playUrl.getUrl());
//                startActivity(intent);
                Intent intent = new Intent(VideoDetailActivity2.this,
                        FXBrowserActivity.class);
                intent.putExtra("url", playUrl.getUrl());
                startActivity(intent);
                saveWatchHistory("风行");
            }
            fl_video_play_background.setVisibility(View.GONE);
            //播放风行视频
            //添加风行播放页
            mFunshionPlayerFragment = new FunshionPlayerFragment();
            Bundle bundle = new Bundle();
            bundle.putSerializable("videoInfo", videoInfo);
            bundle.putSerializable("playUrl", playUrl);
            bundle.putInt("position", mPosition);
            bundle.putBoolean("collect", false);
            bundle.putSerializable("resource", resource);
            mFunshionPlayerFragment.setArguments(bundle);
            if (!mFunshionPlayerFragment.isAdded()) {
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_video_play_container, mFunshionPlayerFragment).commit();
                initPlayer();
            } else if (playUrl.getPlayType() == 2) {//SDK播放
                //播放风行视频
                //添加风行播放页
                mFunshionPlayerFragment = new FunshionPlayerFragment();
                Bundle bundle = new Bundle();
                bundle.putSerializable("videoInfo", videoInfo);
                bundle.putSerializable("playUrl", playUrl);
                bundle.putInt("position", mPosition);
                bundle.putBoolean("collect", false);
                bundle.putSerializable("resource", resource);
                mFunshionPlayerFragment.setArguments(bundle);
                if (!mFunshionPlayerFragment.isAdded()) {
                    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_video_play_container, mFunshionPlayerFragment).commit();
                }
                fl_video_play_background.setVisibility(View.GONE);
            }
        } else {
@@ -430,6 +435,7 @@
                startActivity(intent);
                saveWatchHistory(playUrl.getResource().getName());
            }
            initPlayer();
        }
    }
@@ -439,6 +445,16 @@
    public void onEventMainThread(Playlocation location) {
        fl_ad.setVisibility(View.VISIBLE);
        mPosition = location.getPosition();
    }
    /**
     * 初始化播放器
     */
    private void initPlayer() {
        fl_ad.setVisibility(View.GONE);
        iv_select_play.setVisibility(View.VISIBLE);
        iv_background.setVisibility(View.VISIBLE);
        fl_video_play_background.setVisibility(View.VISIBLE);
    }
@@ -574,9 +590,9 @@
            // Hide the status bar隐藏状态栏
            //测试 不做全屏
//            WindowManager.LayoutParams attrs = getWindow().getAttributes();
//            attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
//            getWindow().setAttributes(attrs);
            WindowManager.LayoutParams attrs = getWindow().getAttributes();
            attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
            getWindow().setAttributes(attrs);
            Fragment videoDetailFragment = getSupportFragmentManager()
                    .findFragmentByTag("VideoDetailFragment");
@@ -891,19 +907,23 @@
                                    }.getType());
                            PlayUrl info = new PlayUrl();
                            info.setResource(resource);
                            info.setPlayType(Integer.parseInt(jsonObject
                                    .getJSONObject("Data")
                                    .optString("PlayType")));
                            info.setUrl(jsonObject.getJSONObject("Data")
                            JSONObject data = jsonObject
                                    .getJSONObject("Data");
                            info.setPlayType(Integer.parseInt(
                                    data.optString("PlayType")));
                            info.setUrl(data
                                    .optString("Url"));
                            info.setParams(jsonObject.getJSONObject("Data")
                            info.setParams(data
                                    .optString("Params"));
                            info.setAid(data.optString("Aid"));
                            info.setVid(data.optString("Vid"));
                            playUrl = info;
                            if (videoInfo == null) {
                                return;
                            }
                            fl_ad.setVisibility(View.VISIBLE);
                            if (!isSetup || isClick) {
                                fl_ad.setVisibility(View.VISIBLE);
                                startPlay();
                                isClick = false;
                            }