| | |
| | | import com.fun.xm.ad.FSThirdAd; |
| | | import com.fun.xm.ad.adloader.FSSRFeedAdLoader; |
| | | import com.fun.xm.ad.adview.FSFeedAD; |
| | | import com.fun.xm.ad.adview.FSPreMediaView; |
| | | import com.fun.xm.ad.callback.FSFeedAdCallBack; |
| | | import com.fun.xm.ad.listener.FSADMediaListener; |
| | | import com.funshion.video.logger.FSLogcat; |
| | | import com.funshion.video.util.FSError; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.MediaView; |
| | | import com.qq.e.ads.nativ.NativeADMediaListener; |
| | | import com.qq.e.ads.nativ.NativeADEventListener; |
| | | import com.qq.e.ads.nativ.NativeUnifiedADData; |
| | | import com.qq.e.comm.constants.AdPatternType; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | | import com.yeshi.video.player.VideoDefinition; |
| | | import com.yeshi.video.player.VideoEpisode; |
| | | import com.yeshi.video.player.VideoPlayerController; |
| | | import com.yeshi.video.player.common.VideoDefinition; |
| | | import com.yeshi.video.player.common.VideoEpisode; |
| | | import com.yeshi.video.player.common.VideoPlayerController; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import de.greenrobot.event.EventBus; |
| | |
| | | |
| | | //风行广告加载器 |
| | | private FSSRFeedAdLoader fssrFeedAdLoader; |
| | | |
| | | private FSPreMediaView mFSVideoAD; |
| | | |
| | | private FunshionPlayInfo playInfo; |
| | | |
| | |
| | | @Override |
| | | public void onAdLoadedFail(int i, String s) { |
| | | Log.i(TAG, "onAdLoadedFail:" + s); |
| | | iadLoadListener.finishAd(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | fsADView.bindAdToView(imageView, clickableViews, null); |
| | | } else if (fsad.isVideo()) { |
| | | MediaView mediaView = new MediaView(getContext()); |
| | | fsADView.bindMediaView(mediaView, getVideoOption(), new NativeADMediaListener() { |
| | | |
| | | fsADView.bindMediaView(mediaView, getVideoOption(), new FSADMediaListener() { |
| | | @Override |
| | | public void onVideoClicked() { |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoError(AdError adError) { |
| | | public void onVideoError(int i, String s) { |
| | | iadLoadListener.finishAd(); |
| | | } |
| | | |
| | |
| | | if (mLayoutInflater == null) |
| | | return; |
| | | gdtAd = ad; |
| | | gdtAd.setNativeAdEventListener(new NativeADEventListener() { |
| | | @Override |
| | | public void onADClicked() { |
| | | Log.v(TAG, "onADClicked"); |
| | | } |
| | | |
| | | @Override |
| | | public void onADError(AdError adError) { |
| | | Log.v(TAG, "onADError"); |
| | | } |
| | | |
| | | @Override |
| | | public void onADExposed() { |
| | | Log.v(TAG, "onADExposed"); |
| | | } |
| | | |
| | | @Override |
| | | public void onADStatusChanged() { |
| | | Log.v(TAG, "onADStatusChanged"); |
| | | } |
| | | }); |
| | | |
| | | final View mContainer = mLayoutInflater.inflate(R.layout.item_funshion_gdt_ad_view, null); |
| | | mDownloadButton = mContainer.findViewById(R.id.btn_download); |
| | | mMediaView = mContainer.findViewById(R.id.gdt_media_view); |
| | |
| | | } |
| | | //作为customClickableViews传入,点击不进入详情页,直接下载或进入落地页,只有视频广告生效, |
| | | // 如果是图文,clickableViews和customClickableViews点击逻辑一致 |
| | | |
| | | fsADView.bindAdToView(mContainer, clickableViews, mDownloadButton); |
| | | |
| | | if (ad.getAdPatternType() == AdPatternType.NATIVE_VIDEO) { |
| | |
| | | Log.v(TAG, "showAd type video 2"); |
| | | mImagePoster.setVisibility(View.GONE); |
| | | mMediaView.setVisibility(View.VISIBLE); |
| | | // ad.startVideo(); |
| | | } |
| | | }); |
| | | |
| | | //4秒内视频还没加载完成的话就跳过 |
| | | tv_skip.removeCallbacks(playADErrorRunnable); |
| | | tv_skip.postDelayed(playADErrorRunnable, 4000); |
| | | fsADView.bindMediaView(mMediaView, getVideoOption(), new NativeADMediaListener() { |
| | | tv_skip.postDelayed(playADErrorRunnable, 10000); |
| | | fsADView.bindMediaView(mMediaView, getVideoOption(), new FSADMediaListener() { |
| | | @Override |
| | | public void onVideoInit() { |
| | | Log.d(TAG, "onVideoInit: "); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoError(AdError error) { |
| | | public void onVideoError(int i, String s) { |
| | | iadLoadListener.finishAd(); |
| | | } |
| | | |
| | | }); |
| | | ad.startVideo(); |
| | | // mMediaView.post(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // ad.startVideo(); |
| | | // } |
| | | // }); |
| | | |
| | | |
| | | } else if (ad.getAdPatternType() == AdPatternType.NATIVE_2IMAGE_2TEXT || |
| | | ad.getAdPatternType() == AdPatternType.NATIVE_1IMAGE_2TEXT) { |
| | |
| | | private void adShowFinish(FunshionPlayInfo info) { |
| | | fl_ad.setVisibility(View.GONE); |
| | | fl_ad.removeAllViews(); |
| | | mFSVideoAD = null; |
| | | //播放视频 |
| | | mVideoSurfView.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //播放视频 |
| | | if (!StringUtils.isNullOrEmpty(info.getPlayUrl().getAid())) |
| | | playMedia(info.getPlayUrl().getAid(), (info.getPosition() + 1) + ""); |
| | | else |
| | | playVideo(info.getPlayUrl().getVid()); |
| | | playVideo(info.getPlayUrl().getCode()); |
| | | } |
| | | }, 1000); |
| | | } |
| | |
| | | /** |
| | | * 播放视频 |
| | | */ |
| | | public synchronized void playVideo(String videoID) { |
| | | public synchronized void playVideo(String code) { |
| | | createPlayer(); |
| | | if (mVideoPlayer.isPlaying()) { |
| | | FSLogcat.e(TAG, "Call player to stop"); |
| | |
| | | } |
| | | //!!!注意播放长短视频构建的FSVideoReqData有区别。短视频没有epso分集ID。长视频有。填写错误将无法正常播放 |
| | | //FSVideoReqData构建需要的数据需要从服务器获取。主要是媒体资源videoID:“VIDEO_ID” 默认 清晰度:new Definition(Definition.CLARITY_LOW) 以及Accesstoken:Accesstoken |
| | | mFSVideoReqData = new FSVideoReqData(videoID, new Definition(Definition.CLARITY_LOW), FunshionConstant.ACCESS_TOKEN); |
| | | mFSVideoReqData = new FSVideoReqData(code, new Definition(Definition.CLARITY_SUPPER)); |
| | | try { |
| | | Log.d(TAG, "request"); |
| | | mFunshionIVideoPlayer.requestAndPrepare(mFSVideoReqData, FunshionConstant.APICODE); |
| | | mFunshionIVideoPlayer.requestAndPrepare(mFSVideoReqData); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 播放媒体 |
| | | */ |
| | | public synchronized void playMedia(String mediaID, String epso) { |
| | | createPlayer(); |
| | | if (mVideoPlayer.isPlaying()) { |
| | | FSLogcat.e(TAG, "Call player to stop"); |
| | | mVideoPlayer.stop(); |
| | | mVideoPlayer.reset(); |
| | | } |
| | | //!!!注意播放长短视频构建的FSVideoReqData有区别。短视频没有epso分集ID。长视频有。填写错误将无法正常播放 |
| | | //FSVideoReqData构建需要的数据需要从服务器获取。主要是媒体资源videoID:“VIDEO_ID”epso 媒体分集ID 默认 清晰度:new Definition(Definition.CLARITY_LOW) 以及Accesstoken:Accesstoken |
| | | mFSVideoReqData = new FSVideoReqData(mediaID, epso, new Definition(Definition.CLARITY_LOW), FunshionConstant.ACCESS_TOKEN); |
| | | try { |
| | | Log.d(TAG, "request"); |
| | | mFunshionIVideoPlayer.requestAndPrepare(mFSVideoReqData, FunshionConstant.APICODE); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public synchronized void stopPlay() { |
| | | if (mVideoPlayer != null && mVideoPlayer.isPlaying()) { |
| | |
| | | FSCallback mFSCall = new FSCallback() { |
| | | |
| | | @Override |
| | | public void onFailed(com.funshion.playsdk.constant.FSError fsError) { |
| | | Log.d(TAG, fsError.errorMessage); |
| | | } |
| | | |
| | | @Override |
| | | public void onDefinition(List<Definition> definitions, Definition currDefinition) { |
| | | for (Definition definition : definitions) { |
| | | Log.e("FE", "get Definition " + definition); |
| | |
| | | vdf.setClarity(mCurrDefinition.getStringDefinition()); |
| | | vdf.setName(getDefinitionName(mCurrDefinition.getStringDefinition())); |
| | | vpc_funshion.setDefinition(vdfList, vdf); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailed(FSError arg0) { |
| | | Log.d(TAG, "onFailed" + arg0); |
| | | } |
| | | |
| | | public void onReceiveUrl(String url) { |
| | |
| | | autoReSize(mediaPlayer); |
| | | else |
| | | autoReSize(mVideoPlayer); |
| | | vpc_funshion.changeOrien(getActivity().getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| | | if (getActivity() != null) |
| | | vpc_funshion.changeOrien(getActivity().getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| | | } |
| | | |
| | | //电池电量监控 |
| | |
| | | |
| | | |
| | | public void onEventMainThread(FunshionPlayInfo info) { |
| | | if (VideoUtil.videoEpisodeList == null || VideoUtil.videoEpisodeList.size() == 0) { |
| | | //加载缓存内容 |
| | | VideoUtil.loadVideoEpisodeListCache(BeibeiVideoApplication.application); |
| | | } |
| | | //风行视频播放 |
| | | MobclickAgent.onEventObject(BeibeiVideoApplication.application, "funtv-play", new HashMap<>()); |
| | | |
| | | Log.i(TAG, "onEventMainThread:FunshionPlayInfo"); |
| | | mCurrentPosition = info.getPosition(); |
| | | List<VideoEpisode> episodes = new ArrayList<>(); |
| | |
| | | episodes.add(es); |
| | | } |
| | | |
| | | vpc_funshion.setContentView(fl_container).setVideoInfo(episodes, info.getPosition(), mVideoInfo.getShowType(), "风行").setVideoPlayerListener(this).build(getActivity(), FunshionPlayerFragment.this); |
| | | loadAD(new IADLoadListener() { |
| | | @Override |
| | | public void finishAd() { |
| | | vpc_funshion.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | tv_skip.setVisibility(View.GONE); |
| | | adShowFinish(info); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | try { |
| | | vpc_funshion.setContentView(fl_container).setVideoInfo(episodes, info.getPosition(), mVideoInfo.getShowType(), "风行").setVideoPlayerListener(this).build(getActivity(), FunshionPlayerFragment.this); |
| | | loadAD(new IADLoadListener() { |
| | | @Override |
| | | public void finishAd() { |
| | | vpc_funshion.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | tv_skip.setVisibility(View.GONE); |
| | | adShowFinish(info); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } catch (Exception e) { |
| | | Log.i(TAG, "出错了:" + e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | if (mVideoPlayer != null && mVideoPlayer.isPlaying()) |
| | | mVideoPlayer.pause(); |
| | | |
| | | //播放统计 |
| | | BeibeiVideoAPI.playStatistic(BeibeiVideoApplication.application, mVideoInfo.getId(), videoResource.getId() + "", new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | |
| | | } |
| | | }); |
| | | |
| | | BeibeiVideoAPI.getPlayUrl(BeibeiVideoApplication.application, uid, detailInfo.getType(), mVideoInfo.getId(), |
| | | detailInfo.getId(), videoResource.getId(), detailInfo.geteId(), |
| | | new BasicTextHttpResponseHandler() { |
| | |
| | | .optString("Params")); |
| | | info.setAid(data.optString("Aid")); |
| | | info.setVid(data.optString("Vid")); |
| | | info.setCode(jsonObject.getJSONObject("Data") |
| | | .optString("Code")); |
| | | playInfo.setPlayUrl(info); |
| | | mShowAd = false; |
| | | EventBus.getDefault().post(playInfo); |