| | |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.bumptech.glide.request.target.SimpleTarget; |
| | | import com.bumptech.glide.request.transition.Transition; |
| | | import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | |
| | | import com.weikou.beibeivideo.entity.VideoDetailInfo; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.entity.video.ChangeVideoEvent; |
| | | 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.video.VideoPlayerBrowserActivity; |
| | | import com.weikou.beibeivideo.ui.video.FunshionPlayerFragment; |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.ad.FullVideoAdManager; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | | |
| | |
| | | public class VideoDetailActivity2 extends BaseActivity implements |
| | | OnClickListener { |
| | | |
| | | private final String TAG = "VideoDetailActivity2"; |
| | | private final String TAG = VideoDetailActivity2.class.getName(); |
| | | |
| | | // private boolean mLandscape; |
| | | private VideoInfo videoInfo; |
| | |
| | | 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 |
| | | public void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.video_detail_activity); |
| | | VideoUtil.clearVideoEpisodeList(this); |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | |
| | | .commitAllowingStateLoss(); |
| | | } |
| | | iNet(); |
| | | |
| | | if (fl_ad != null) |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | |
| | |
| | | if (BeibeiConstant.AD_TYPE.isVideoDetailSplashAd()) { |
| | | if (FullVideoAdManager.getInstance().isCacahed()) { |
| | | FullVideoAdManager.getInstance().showAd(this); |
| | | } else { |
| | | FullVideoAdManager.getInstance().loadAd(BeibeiVideoApplication.application, new FullVideoAdManager.IFullVideoAdListener() { |
| | | @Override |
| | | public void onSuccess(TTFullScreenVideoAd ad) { |
| | | FullVideoAdManager.getInstance().showAd(VideoDetailActivity2.this); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (BeibeiConstant.IS_TEST) |
| | | BeibeiConstant.AD_TYPE = null; |
| | | //需要加载广告 |
| | | if (BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isPlayerAd()) { |
| | | if (BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isPlayerAd() && playUrl.getPlayType() != 2) { |
| | | mVideoDetailVideoAdFragment = new PlayVideoPreADFragment(); |
| | | mVideoDetailVideoAdFragment.setPageEventListener(new IPageEventListener() { |
| | | @Override |
| | |
| | | mVideoDetailVideoAdFragment.loadVideoAD(new PlayVideoPreADFragment.IVideoAdListener() { |
| | | @Override |
| | | public void finishPlay() { |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commit(); |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commitAllowingStateLoss(); |
| | | clickPlay();//进入播放事件 |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void noAd() { |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commit(); |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commitAllowingStateLoss(); |
| | | clickPlay();//进入播放事件 |
| | | } |
| | | }); |
| | |
| | | }); |
| | | |
| | | if (!mVideoDetailVideoAdFragment.isAdded()) { |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_ad, mVideoDetailVideoAdFragment).commit(); |
| | | } |
| | | |
| | |
| | | videoInfo.getResourceList().get(i).setChecked(false); |
| | | } |
| | | } |
| | | |
| | | //播放统计 |
| | | BeibeiVideoAPI.playStatistic(BeibeiVideoApplication.application, videoInfo.getId(), playUrl.getResource().getId() + "", new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | |
| | | } |
| | | }); |
| | | |
| | | if (playUrl.getResource().getName().contains("爱奇艺")) { |
| | | if (playUrl != null) { |
| | | if (playUrl.getPlayType() == 0) { |
| | |
| | | return; |
| | | } else if (playUrl.getPlayType() == 1) { |
| | | Intent intent = new Intent(VideoDetailActivity2.this, |
| | | VideoPlayerActivity.class); |
| | | VideoPlayerBrowserActivity.class); |
| | | intent.putExtra("url", playUrl.getUrl()); |
| | | startActivity(intent); |
| | | initPlayer(); |
| | | } else if (playUrl.getPlayType() == 2) { |
| | | iv_select_play.setVisibility(View.GONE); |
| | | iv_background.setClickable(false); |
| | |
| | | // EventBus.getDefault().post(playUrl); |
| | | Toast.makeText(VideoDetailActivity2.this, "影片加载中...", |
| | | Toast.LENGTH_LONG).show(); |
| | | initPlayer(); |
| | | } |
| | | saveWatchHistory("爱奇艺"); |
| | | } |
| | | |
| | | } else if (playUrl.getResource().getName().contains("风行")) { |
| | | |
| | | if (playUrl.getPlayType() == 0) { |
| | |
| | | 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, |
| | | VideoPlayerBrowserActivity.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 { |
| | |
| | | return; |
| | | } else if (playUrl.getPlayType() == 1) { |
| | | Intent intent = new Intent(VideoDetailActivity2.this, |
| | | VideoPlayerActivity.class); |
| | | VideoPlayerBrowserActivity.class); |
| | | intent.putExtra("url", playUrl.getUrl()); |
| | | startActivity(intent); |
| | | saveWatchHistory(playUrl.getResource().getName()); |
| | | } |
| | | initPlayer(); |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 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"); |
| | |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | Log.i(TAG, "onResume"); |
| | | super.onResume(); |
| | | EventBus.getDefault().register(this); |
| | | if (fl_ad.getVisibility() == View.GONE) { |
| | |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | Log.i(TAG, "onPause"); |
| | | super.onPause(); |
| | | EventBus.getDefault().unregister(this); |
| | | } |
| | |
| | | } catch (IndexOutOfBoundsException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void onEventMainThread(VideoInfo info) { |
| | |
| | | .toString(), |
| | | new TypeToken<VideoInfo>() { |
| | | }.getType()); |
| | | if (videoInfo != null) { |
| | | VideoUtil.saveVideoEpisodeList(BeibeiVideoApplication.application, videoInfo.getVideoDetailList(), false); |
| | | } |
| | | // 附加字段 |
| | | if (jsonObject.optJSONObject("Extra1") != null) { |
| | | if (jsonObject.optJSONObject("Extra1").optJSONObject("Attention") != null) { |
| | |
| | | resource = videoInfo.getResourceList().get(i); |
| | | } |
| | | } |
| | | if (videoInfo.getVideoDetailList() == null |
| | | || videoInfo.getVideoDetailList().isEmpty()) { |
| | | if (VideoUtil.videoEpisodeList == null |
| | | || VideoUtil.videoEpisodeList.isEmpty()) { |
| | | Toast.makeText(VideoDetailActivity2.this, |
| | | "影片已删除", Toast.LENGTH_LONG).show(); |
| | | finish(); |
| | |
| | | if (isFromWatchHistory || position > 0) { |
| | | mPosition = getIntent().getIntExtra("playing_position", 0); |
| | | EventBus.getDefault().post(videoInfo); |
| | | getUrl(videoInfo.getVideoDetailList().get(mPosition), isSetup); |
| | | EventBus.getDefault().post(videoInfo.getVideoDetailList().get(mPosition)); |
| | | getUrl(VideoUtil.videoEpisodeList.get(mPosition), isSetup); |
| | | EventBus.getDefault().post(VideoUtil.videoEpisodeList.get(mPosition)); |
| | | } else {// 不是从观看记录点击过来 --跳到当前播放的集数 |
| | | // position = VideoPlayUrlUtil |
| | | // .getVideoDetailPosition(context, |
| | | // videoInfo); |
| | | EventBus.getDefault().post(videoInfo); |
| | | if (StringUtils.isEmpty(detailid)) { |
| | | getUrl(videoInfo.getVideoDetailList().get( |
| | | getUrl(VideoUtil.videoEpisodeList.get( |
| | | position), isSetup); |
| | | EventBus.getDefault().post( |
| | | videoInfo.getVideoDetailList().get( |
| | | VideoUtil.videoEpisodeList.get( |
| | | position)); |
| | | } else { |
| | | if (videoInfo.getVideoDetailList() != null) |
| | | for (int i = 0; i < videoInfo.getVideoDetailList().size(); i++) { |
| | | if (detailid.equalsIgnoreCase(videoInfo.getVideoDetailList().get(i).getId())) { |
| | | getUrl(videoInfo.getVideoDetailList().get( |
| | | if (VideoUtil.videoEpisodeList != null) |
| | | for (int i = 0; i < VideoUtil.videoEpisodeList.size(); i++) { |
| | | if (detailid.equalsIgnoreCase(VideoUtil.videoEpisodeList.get(i).getId())) { |
| | | getUrl(VideoUtil.videoEpisodeList.get( |
| | | i), false); |
| | | PushEpisode info = new PushEpisode(); |
| | | info.setEpisodeNum(i); |
| | | EventBus.getDefault().post( |
| | | videoInfo.getVideoDetailList().get( |
| | | VideoUtil.videoEpisodeList.get( |
| | | i)); |
| | | } |
| | | } |
| | |
| | | resource = videoInfo.getResourceList().get(i); |
| | | } |
| | | } |
| | | getUrl(videoInfo.getVideoDetailList().get(0), |
| | | isSetup); |
| | | getUrl(VideoUtil.videoEpisodeList.get(0), |
| | | true); |
| | | findViewById(android.R.id.content).postDelayed( |
| | | new Runnable() { |
| | | |
| | |
| | | EventBus.getDefault().post( |
| | | videoInfo); |
| | | EventBus.getDefault() |
| | | .post(videoInfo |
| | | .getVideoDetailList() |
| | | .post(VideoUtil.videoEpisodeList |
| | | .get(0)); |
| | | } |
| | | }, 200); |
| | |
| | | }.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")); |
| | | info.setCode(jsonObject.getJSONObject("Data") |
| | | .optString("Code")); |
| | | playUrl = info; |
| | | if (videoInfo == null) { |
| | | return; |
| | | } |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | |
| | | if (!isSetup || isClick) { |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | startPlay(); |
| | | isClick = false; |
| | | } |
| | |
| | | Log.i(TAG, "update"); |
| | | } |
| | | |
| | | public static class ChangeVideoEvent { |
| | | private VideoInfo videoInfo; |
| | | |
| | | private String tag; |
| | | |
| | | public VideoInfo getVideoInfo() { |
| | | return videoInfo; |
| | | } |
| | | |
| | | public void setVideoInfo(VideoInfo videoInfo) { |
| | | this.videoInfo = videoInfo; |
| | | } |
| | | |
| | | public String getTag() { |
| | | return tag; |
| | | } |
| | | |
| | | public void setTag(String tag) { |
| | | this.tag = tag; |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | |
| | | * video网络数据请求 |
| | | */ |
| | | private void iNet() { |
| | | if (videoInfo.getVideoDetailList() == null |
| | | || videoInfo.getVideoDetailList().isEmpty()) { |
| | | if (VideoUtil.videoEpisodeList == null |
| | | || VideoUtil.videoEpisodeList.isEmpty()) { |
| | | getVideoDetail(this, videoInfo.getId(), videoInfo.getThirdType(), |
| | | true); |
| | | } else { |
| | |
| | | public void run() { |
| | | EventBus.getDefault().post(videoInfo); |
| | | EventBus.getDefault().post( |
| | | videoInfo.getVideoDetailList().get( |
| | | VideoUtil.videoEpisodeList.get( |
| | | getIntent().getIntExtra("playing_position", |
| | | 0))); |
| | | } |
| | |
| | | private void saveWatchHistory(String from) { |
| | | if (videoInfo != null) { |
| | | String videoDetailId = ""; |
| | | if (videoInfo.getVideoDetailList() == null || videoInfo.getVideoDetailList().size() == 0) |
| | | if (VideoUtil.videoEpisodeList == null || VideoUtil.videoEpisodeList.size() == 0) |
| | | return; |
| | | if (mPosition >= videoInfo.getVideoDetailList().size()) { |
| | | videoDetailId = videoInfo.getVideoDetailList().get(0) |
| | | if (mPosition >= VideoUtil.videoEpisodeList.size()) { |
| | | videoDetailId = VideoUtil.videoEpisodeList.get(0) |
| | | .getId(); |
| | | } else { |
| | | videoDetailId = videoInfo.getVideoDetailList().get(mPosition) |
| | | videoDetailId = VideoUtil.videoEpisodeList.get(mPosition) |
| | | .getId(); |
| | | } |
| | | String resoureID = ""; |