| | |
| | | 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.lcjian.library.util.SystemCommon; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.video.VideoDataNotifyDialog; |
| | | import com.lcjian.library.video.VideoLoadingDialog; |
| | | import com.loopj.android.http.JsonHttpResponseHandler; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.db.WatchHistoryTable; |
| | | import com.weikou.beibeivideo.entity.AccumulateRule; |
| | | import com.weikou.beibeivideo.entity.Follow; |
| | |
| | | import com.weikou.beibeivideo.ui.common.ShareActivity; |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | 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; |
| | | import com.weikou.beibeivideo.util.ad.FullVideoAdManager; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONArray; |
| | |
| | | // |
| | | public class VideoDetailActivity extends BaseActivity implements |
| | | OnClickListener { |
| | | |
| | | private final static String TAG = "VideoDetailActivity"; |
| | | |
| | | // private boolean mLandscape; |
| | | private VideoInfo videoInfo; |
| | |
| | | |
| | | private VideoDetailVideoAdFragment mVideoDetailVideoAdFragment; |
| | | |
| | | //风行播放器 |
| | | private FunshionPlayerFragment mFunshionPlayerFragment; |
| | | |
| | | private ImageView iv_select_play; |
| | | |
| | | private FrameLayout fl_ad; |
| | | |
| | | |
| | | @Override |
| | | protected void onSaveInstanceState(Bundle outState) { |
| | |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.video_detail_activity); |
| | | |
| | | new VideoDataNotifyDialog.Builder().build(this).show(); |
| | | |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | |
| | | //广告 |
| | | /** |
| | | * 广告 |
| | | */ |
| | | mVideoDetailVideoAdFragment = new VideoDetailVideoAdFragment(); |
| | | //播放器 |
| | | mFunshionPlayerFragment = new FunshionPlayerFragment(); |
| | | |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_ad, mVideoDetailVideoAdFragment).commit(); |
| | | |
| | | |
| | | initView(); |
| | | |
| | |
| | | if (videoInfo == null) { |
| | | return; |
| | | } |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | isClick = true; |
| | | startPlay(); |
| | | } |
| | |
| | | } |
| | | iNet(); |
| | | |
| | | if (fl_ad != null) |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | // 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(VideoDetailActivity.this); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | |
| | | private int mPosition = 0; |
| | | |
| | | public void onEventMainThread(Playlocation location) { |
| | | Log.i(TAG, "onEventMainThread:Playlocation"); |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | mPosition = location.getPosition(); |
| | | } |
| | |
| | | |
| | | private boolean isFirst = true; |
| | | |
| | | private synchronized void startPlay() { |
| | | //移除所有的fragment |
| | | if (mVideoDetailVideoAdFragment.isAdded()) { |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commit(); |
| | | } |
| | | |
| | | if (mFunshionPlayerFragment.isAdded()) { |
| | | getSupportFragmentManager().beginTransaction().remove(mFunshionPlayerFragment).commit(); |
| | | } |
| | | private void startPlay() { |
| | | |
| | | iv_select_play.setVisibility(View.GONE); |
| | | //需要加载广告 |
| | | if (BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isPlayerAd()) { |
| | | mVideoDetailVideoAdFragment = new VideoDetailVideoAdFragment(); |
| | | mVideoDetailVideoAdFragment.setPageEventListener(new IPageEventListener() { |
| | | |
| | | if (fl_ad.getVisibility() == View.VISIBLE && BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isPlayerAd()) { |
| | | mVideoDetailVideoAdFragment.loadVideoAD(new VideoDetailVideoAdFragment.IVideoAdListener() { |
| | | @Override |
| | | public void onCreateView() { |
| | | mVideoDetailVideoAdFragment.loadVideoAD(new VideoDetailVideoAdFragment.IVideoAdListener() { |
| | | @Override |
| | | public void finishPlay() { |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment); |
| | | clickPlay();//进入播放事件 |
| | | } |
| | | public void finishPlay() { |
| | | clickPlay(); |
| | | fl_ad.setVisibility(View.GONE); |
| | | } |
| | | |
| | | @Override |
| | | public void startPlay() { |
| | | @Override |
| | | public void startPlay() { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | if (!mVideoDetailVideoAdFragment.isAdded()) { |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_ad, mVideoDetailVideoAdFragment).commit(); |
| | | } |
| | | |
| | | } else {//进入播放视频事件 |
| | | } else { |
| | | clickPlay(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | Toast.LENGTH_LONG).show(); |
| | | return; |
| | | } else if (playUrl.getPlayType() == 1) { |
| | | // Intent intent = new Intent(VideoDetailActivity.this, |
| | | // FXBrowserActivity.class); |
| | | // intent.putExtra("url", playUrl.getUrl()); |
| | | // startActivity(intent); |
| | | Intent intent = new Intent(VideoDetailActivity.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.putString("vid", "83693903"); |
| | | mFunshionPlayerFragment.setArguments(bundle); |
| | | if (!mFunshionPlayerFragment.isAdded()) { |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fragment_video_play_container, mFunshionPlayerFragment).commit(); |
| | | } |
| | | //开始播放视频 |
| | | } else { |
| | | if (playUrl.getPlayType() == 0) { |
| | | Toast.makeText(VideoDetailActivity.this, "此节目不可播!", |
| | |
| | | |
| | | @Override |
| | | public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { |
| | | ((ImageView) findViewById(R.id.iv_video_play_background)) |
| | | iv_background |
| | | .setImageDrawable(resource); |
| | | } |
| | | |
| | |
| | | private void checkConfiguration(Configuration newConfig) { |
| | | if (newConfig == null) |
| | | return; |
| | | if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {//横屏 |
| | | if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { |
| | | // Hide the status bar隐藏状态栏 |
| | | WindowManager.LayoutParams attrs = getWindow().getAttributes(); |
| | | attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| | |
| | | R.id.fragment_video_play_container).getLayoutParams(); |
| | | layoutParams.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT; |
| | | findViewById(R.id.fragment_video_play_container).requestLayout(); |
| | | |
| | | |
| | | } else { |
| | | // Show the status bar显示状态栏 |
| | | WindowManager.LayoutParams attrs = getWindow().getAttributes(); |
| | |
| | | .toString(), |
| | | new TypeToken<VideoInfo>() { |
| | | }.getType()); |
| | | |
| | | // 附加字段 |
| | | if (jsonObject.optJSONObject("Extra1") != null) { |
| | | if (jsonObject.optJSONObject("Extra1").optJSONObject("Attention") != null) { |
| | |
| | | progressDialog.dismiss(); |
| | | } |
| | | |
| | | //加载视频广告 |
| | | loadFullVideoAd(); |
| | | fl_ad.setVisibility(View.GONE); |
| | | |
| | | if (!BeibeiConstant.IS_TEST) |
| | | //加载视频广告 |
| | | loadFullVideoAd(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | if (videoInfo == null) { |
| | | return; |
| | | } |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | Log.i(TAG, "getUrl"); |
| | | if (!isSetup || isClick) { |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | startPlay(); |
| | | isClick = false; |
| | | } |
| | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | if (BeibeiConstant.AD_TYPE.isVideoDetailSplashAd()) |
| | | FullVideoAdManager.getInstance().loadAd(getApplicationContext(), null); |
| | | } |
| | | } |