| | |
| | | package com.weikou.beibeivideo.ui.video; |
| | | |
| | | import android.content.BroadcastReceiver; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.IntentFilter; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.content.res.Configuration; |
| | | import android.media.MediaPlayer; |
| | | import android.net.ConnectivityManager; |
| | | import android.net.NetworkInfo; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.support.annotation.Nullable; |
| | | import android.util.Log; |
| | | import android.view.SurfaceHolder; |
| | | import android.view.SurfaceView; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.Toast; |
| | | |
| | | import com.fun.xm.Definition; |
| | |
| | | import com.fun.xm.FSIVideoPlayer; |
| | | import com.fun.xm.FSPlayer; |
| | | import com.fun.xm.FSVideoReqData; |
| | | import com.fun.xm.ad.FSAD; |
| | | import com.fun.xm.ad.FSThirdAd; |
| | | import com.fun.xm.ad.adloader.FSPreMediaAdLoader; |
| | | import com.fun.xm.ad.adview.FSPreMediaView; |
| | | import com.fun.xm.ad.callback.FSPreMediaAdCallBack; |
| | | 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.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.lcjian.library.video.VideoDefinition; |
| | | import com.lcjian.library.video.VideoEpisode; |
| | | import com.lcjian.library.video.VideoPlayerController; |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.Play; |
| | | import com.weikou.beibeivideo.entity.PlayUrl; |
| | | import com.weikou.beibeivideo.entity.VideoDetailInfo; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.entity.video.FunshionPlayInfo; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.FunshionConstant; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | public class FunshionPlayerFragment extends RetainViewFragment implements OnClickListener { |
| | | private final static String TAG = FunshionPlayerFragment.class.getName(); |
| | | import de.greenrobot.event.EventBus; |
| | | |
| | | private final static String ACCESS_TOKEN = "Zms4NHZseSwxNjAwNDE4MDQ0LDU0MmQyNDI5ZjY5MGQwODM1OTcyYTM3MDMwOTg3MzNj"; |
| | | public final static String APICODE = "fk84vly"; |
| | | public class FunshionPlayerFragment extends RetainViewFragment implements OnClickListener, VideoPlayerController.IVideoPlayerListener { |
| | | private final static String TAG = FunshionPlayerFragment.class.getName(); |
| | | |
| | | //媒体视频播放器 |
| | | private MediaPlayer mVideoPlayer = new MediaPlayer(); |
| | |
| | | |
| | | private IPageEventListener pageEventListener; |
| | | |
| | | private VideoInfo mVideoInfo; |
| | | private int mCurrentPosition; |
| | | private PlayUrl playUrl; |
| | | private boolean collected; |
| | | private VideoResource videoResource; |
| | | |
| | | private VideoPlayerController vpc_funshion; |
| | | |
| | | private RatioLayout rl_container; |
| | | |
| | | private FrameLayout fl_container, fl_ad; |
| | | |
| | | //风行广告加载器 |
| | | private FSPreMediaAdLoader fsPreMediaAdLoader; |
| | | |
| | | private FSPreMediaView mFSVideoAD; |
| | | |
| | | private FunshionPlayInfo playInfo; |
| | | |
| | | private MediaPlayer mediaPlayer; |
| | | |
| | | public void setPageEventListener(IPageEventListener pageEventListener) { |
| | | this.pageEventListener = pageEventListener; |
| | |
| | | mVideoPlayer.setOnErrorListener(mOnErrorListener); |
| | | initAccessToken(); |
| | | if (getArguments() != null) { |
| | | String mediaId = getArguments().getString("mediaId"); |
| | | String ep = getArguments().getString("ep"); |
| | | String vid = getArguments().getString("vid"); |
| | | mVideoSurfView.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (StringUtils.isNullOrEmpty(vid)) |
| | | playMedia(mediaId, ep); |
| | | else |
| | | playVideo(vid); |
| | | } |
| | | }, 1000); |
| | | mVideoInfo = (VideoInfo) getArguments().getSerializable("videoInfo"); |
| | | mCurrentPosition = getArguments().getInt("position", 0); |
| | | playUrl = (PlayUrl) getArguments().getSerializable("playUrl"); |
| | | collected = getArguments().getBoolean("collect", false); |
| | | videoResource = (VideoResource) getArguments().getSerializable("resource"); |
| | | |
| | | playInfo = new FunshionPlayInfo(); |
| | | playInfo.setCollected(collected); |
| | | playInfo.setPlayUrl(playUrl); |
| | | playInfo.setPosition(mCurrentPosition); |
| | | playInfo.setVideoInfo(mVideoInfo); |
| | | } |
| | | vpc_funshion.setContentView(mVideoSurfView); |
| | | vpc_funshion.build(getActivity()); |
| | | |
| | | } |
| | | |
| | | private void initAd() { |
| | | FSAD.init(getContext().getApplicationContext(), Collections.singletonList(FunshionConstant.AD_ADP), FunshionConstant.AD_PARTENER, FunshionConstant.AD_TOKEN, FunshionConstant.AD_CHANNEL, FunshionConstant.AD_PRE_DOWNLOAD_CHANNEL); |
| | | fsPreMediaAdLoader = new FSPreMediaAdLoader(getContext(), FunshionConstant.AD_CHANNEL); |
| | | } |
| | | |
| | | private void loadAD() { |
| | | String adid = "bfys_a_qt"; |
| | | int width = fl_ad.getWidth(); |
| | | int height = fl_ad.getHeight(); |
| | | Log.i(TAG, String.format("fl_ad: width:%s height:%s", width, height)); |
| | | fsPreMediaAdLoader.loadAD(adid, "", width, height, true, false, new FSPreMediaAdCallBack() { |
| | | @Override |
| | | public void onCreate(FSPreMediaView fsadView) { |
| | | mFSVideoAD = fsadView; |
| | | fl_ad.removeAllViews(); |
| | | fl_ad.addView(fsadView); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateThirdAD(List<FSThirdAd> fsThirdAd) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onClose() { |
| | | adShowFinish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onADLoad() { |
| | | if (null != mFSVideoAD) { |
| | | mFSVideoAD.showAD(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoComplete() { |
| | | adShowFinish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onADShow() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onClick() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdLoadedFail(int param1Int, String param1String) { |
| | | Log.v(TAG, "onAdLoadedFail param1Int:" + param1Int + " MSG:" + param1String); |
| | | adShowFinish(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //广告展示完成 |
| | | private void adShowFinish() { |
| | | fl_ad.setVisibility(View.GONE); |
| | | fl_ad.removeAllViews(); |
| | | mFSVideoAD = null; |
| | | //播放视频 |
| | | mVideoSurfView.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | EventBus.getDefault().post(playInfo); |
| | | } |
| | | }, 1000); |
| | | } |
| | | |
| | | private void initView(View view) { |
| | | mVideoSurfView = view.findViewById(R.id.video_view); |
| | | vpc_funshion = view.findViewById(R.id.vpc_funshion); |
| | | rl_container = view.findViewById(R.id.rl_container); |
| | | fl_container = view.findViewById(R.id.fl_container); |
| | | fl_ad = view.findViewById(R.id.fl_ad); |
| | | } |
| | | |
| | | //创建广播接受者对象 |
| | | BatteryReceiver batteryReceiver = new BatteryReceiver(); |
| | | NetworkReceiver networkReceiver = new NetworkReceiver(); |
| | | |
| | | @Override |
| | | public void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | //注册receiver |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | initView(contentView); |
| | | initPlayer(); |
| | | getContext().registerReceiver(batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); |
| | | getContext().registerReceiver(networkReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); |
| | | initAd(); |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | fl_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | loadAD(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroyView() { |
| | | super.onDestroyView(); |
| | | getContext().unregisterReceiver(batteryReceiver); |
| | | getContext().unregisterReceiver(networkReceiver); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | //!!!注意播放长短视频构建的FSVideoReqData有区别。短视频没有epso分集ID。长视频有。填写错误将无法正常播放 |
| | | //FSVideoReqData构建需要的数据需要从服务器获取。主要是媒体资源videoID:“VIDEO_ID” 默认 清晰度:new Definition(Definition.CLARITY_LOW) 以及Accesstoken:Accesstoken |
| | | mFSVideoReqData = new FSVideoReqData(videoID, new Definition(Definition.CLARITY_LOW), ACCESS_TOKEN); |
| | | mFSVideoReqData = new FSVideoReqData(videoID, new Definition(Definition.CLARITY_LOW), FunshionConstant.ACCESS_TOKEN); |
| | | try { |
| | | Log.d(TAG, "request"); |
| | | |
| | | mFunshionIVideoPlayer.requestAndPrepare(mFSVideoReqData, APICODE); |
| | | mFunshionIVideoPlayer.requestAndPrepare(mFSVideoReqData, FunshionConstant.APICODE); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | //!!!注意播放长短视频构建的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), ACCESS_TOKEN); |
| | | mFSVideoReqData = new FSVideoReqData(mediaID, epso, new Definition(Definition.CLARITY_LOW), FunshionConstant.ACCESS_TOKEN); |
| | | try { |
| | | Log.d(TAG, "request"); |
| | | mFunshionIVideoPlayer.requestAndPrepare(mFSVideoReqData, APICODE); |
| | | mFunshionIVideoPlayer.requestAndPrepare(mFSVideoReqData, FunshionConstant.APICODE); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private String getDefinitionName(String clarity) { |
| | | switch (clarity) { |
| | | case "tv": |
| | | case "dvd": |
| | | return "标清"; |
| | | case "hd": |
| | | return "高清"; |
| | | case "sdvd": |
| | | return "超清"; |
| | | default: |
| | | return "标清"; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | private String videoPlayUrl = ""; |
| | | |
| | | |
| | | FSCallback mFSCall = new FSCallback() { |
| | | |
| | |
| | | } |
| | | FunshionPlayerFragment.this.mDefinitions = definitions; |
| | | FunshionPlayerFragment.this.mCurrDefinition = currDefinition; |
| | | |
| | | //设置清晰度 |
| | | List<VideoDefinition> vdfList = new ArrayList<>(); |
| | | if (definitions != null) |
| | | for (Definition df : definitions) { |
| | | VideoDefinition vdf = new VideoDefinition(); |
| | | vdf.setClarity(df.getStringDefinition()); |
| | | vdf.setName(getDefinitionName(df.getStringDefinition())); |
| | | vdfList.add(vdf); |
| | | } |
| | | VideoDefinition vdf = new VideoDefinition(); |
| | | vdf.setClarity(mCurrDefinition.getStringDefinition()); |
| | | vdf.setName(getDefinitionName(mCurrDefinition.getStringDefinition())); |
| | | |
| | | vpc_funshion.setDefinition(vdfList, vdf); |
| | | |
| | | Toast.makeText(BeibeiVideoApplication.application, "当前清晰度:" + currDefinition.getStringDefinition(), Toast.LENGTH_LONG).show(); |
| | | } |
| | | |
| | |
| | | public void onReceiveUrl(String url) { |
| | | Log.d(TAG, "onReceiveUrl" + url); |
| | | try { |
| | | videoPlayUrl = url; |
| | | mVideoPlayer.reset(); |
| | | mVideoPlayer.setDataSource(url); |
| | | mVideoPlayer.prepareAsync(); |
| | |
| | | } |
| | | }; |
| | | |
| | | boolean isReady = false; |
| | | |
| | | int position = 0; |
| | | |
| | | SurfaceHolder.Callback mVideoSurfaceViewCallBack = new SurfaceHolder.Callback() { |
| | | |
| | | @Override |
| | | public void surfaceDestroyed(SurfaceHolder holder) { |
| | | isReady = false; |
| | | |
| | | Log.d(TAG, "surfaceDestroyed"); |
| | | if (mVideoPlayer.isPlaying()) { |
| | | position = mVideoPlayer.getCurrentPosition(); |
| | | Log.d(TAG, "当前播放时间:" + position); |
| | | mVideoPlayer.stop(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void surfaceCreated(SurfaceHolder holder) { |
| | | Log.d(TAG, "surfaceCreated"); |
| | | isReady = true; |
| | | mVideoPlayer.setDisplay(holder); |
| | | if (!"".equals(videoPlayUrl) && !mVideoPlayer.isPlaying()) { |
| | | try { |
| | | mVideoPlayer.reset(); |
| | | mVideoPlayer.setDataSource(videoPlayUrl); |
| | | mVideoPlayer.prepare(); |
| | | if (position > 0) |
| | | mVideoPlayer.seekTo(position); |
| | | position = -1; |
| | | Log.d(TAG, "续播时间:" + position); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
| | | |
| | | Log.d(TAG, "surfaceChanged"); |
| | | } |
| | | }; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onPrepared(MediaPlayer mp) { |
| | | Log.i(TAG, "onPrepared"); |
| | | mediaPlayer = mp; |
| | | mFunshionIVideoPlayer.onMediaPlayerPrepared(); |
| | | mp.start(); |
| | | autoReSize(mp); |
| | | vpc_funshion.onPrepared(mp); |
| | | if (position > 0) |
| | | mVideoPlayer.seekTo(position); |
| | | } |
| | | }; |
| | | |
| | | private void autoReSize(MediaPlayer mp) { |
| | | Log.i(TAG, "autoReSize"); |
| | | final int vWidth = mp.getVideoWidth(); |
| | | final int vHeight = mp.getVideoHeight(); |
| | | if (vHeight == 0 || vWidth == 0) |
| | | return; |
| | | //获取容器的宽 |
| | | fl_container.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | float ratio = new BigDecimal(vHeight).divide(new BigDecimal(vWidth), 4, RoundingMode.FLOOR).floatValue(); |
| | | int cwidth = fl_container.getWidth(); |
| | | int cheight = fl_container.getHeight(); |
| | | Log.i(TAG, String.format("MediaPlayer: width-%s height-%s", vWidth, vHeight)); |
| | | |
| | | ViewGroup.LayoutParams params = rl_container.getLayoutParams(); |
| | | if (vHeight * cwidth > vWidth * cheight) { |
| | | Log.i(TAG, "宽自适应"); |
| | | params.height = fl_container.getHeight(); |
| | | params.width = (int) (params.height / ratio); |
| | | } else { |
| | | Log.i(TAG, "高自适应"); |
| | | params.width = fl_container.getWidth(); |
| | | params.height = (int) (params.width * ratio); |
| | | } |
| | | rl_container.setLayoutParams(params); |
| | | |
| | | rl_container.setRatio(ratio); |
| | | Log.i(TAG, String.format("Ratio: %s", ratio)); |
| | | |
| | | mVideoSurfView.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Log.i(TAG, String.format("mVideoSurfView: width-%s height-%s", mVideoSurfView.getWidth(), mVideoSurfView.getHeight())); |
| | | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | MediaPlayer.OnErrorListener mOnErrorListener = new MediaPlayer.OnErrorListener() { |
| | | |
| | |
| | | mFunshionIVideoPlayer.onActivityDestroy(); |
| | | mFunshionIVideoPlayer.release(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | super.onStop(); |
| | | if (mVideoPlayer != null && mVideoPlayer.isPlaying()) |
| | | mVideoPlayer.pause(); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | if (mFunshionIVideoPlayer != null) |
| | | mFunshionIVideoPlayer.onActivityResume(); |
| | | EventBus.getDefault().register(this); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | if (mVideoPlayer.isPlaying()) |
| | | mVideoPlayer.pause(); |
| | | if (mFunshionIVideoPlayer != null) |
| | | mFunshionIVideoPlayer.onActivityPause(); |
| | | EventBus.getDefault().unregister(this); |
| | | } |
| | | |
| | | |
| | | public void requestLayout() { |
| | | Log.i(TAG, "requestLayout"); |
| | | if (mediaPlayer != null) |
| | | autoReSize(mediaPlayer); |
| | | else |
| | | autoReSize(mVideoPlayer); |
| | | vpc_funshion.changeOrien(getActivity().getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| | | } |
| | | |
| | | //电池电量监控 |
| | | class BatteryReceiver extends BroadcastReceiver { |
| | | |
| | | @Override |
| | | public void onReceive(Context context, Intent intent) { |
| | | // TODO Auto-generated method stub |
| | | //判断它是否是为电量变化的Broadcast Action |
| | | if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {//电量变化 |
| | | //获取当前电量 |
| | | int level = intent.getIntExtra("level", 0); |
| | | //电量的总刻度 |
| | | int scale = intent.getIntExtra("scale", 100); |
| | | //把它转成百分比 |
| | | if (vpc_funshion != null) |
| | | vpc_funshion.setBattery((level * 100) / scale); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public class NetworkReceiver extends BroadcastReceiver { |
| | | public void onReceive(Context context, Intent intent) { |
| | | String action = intent.getAction(); |
| | | if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { |
| | | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); |
| | | NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); |
| | | vpc_funshion.setNetworkInfo(networkInfo, false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public void onEventMainThread(FunshionPlayInfo info) { |
| | | List<VideoEpisode> episodes = new ArrayList<>(); |
| | | for (int i = 0; i < info.getVideoInfo().getVideoDetailList().size(); i++) { |
| | | VideoDetailInfo detail = info.getVideoInfo().getVideoDetailList().get(i); |
| | | VideoEpisode es = new VideoEpisode(); |
| | | es.setId(detail.getId()); |
| | | es.setTag(detail.getTag()); |
| | | es.setVideoId(info.getVideoInfo().getId()); |
| | | episodes.add(es); |
| | | } |
| | | mCurrentPosition = info.getPosition(); |
| | | vpc_funshion.setContentView(fl_container).setVideoInfo(episodes, info.getVideoInfo().getName(), info.getPlayUrl().getUrl(), info.getPosition()).setVideoPlayerListener(this).build(getActivity(), FunshionPlayerFragment.this); |
| | | //播放视频 |
| | | // playVideo(info.getVideoInfo().getVideoDetailList().get(info.getPosition()).getId()); |
| | | |
| | | playMedia("99989", (info.getPosition() + 1) + ""); |
| | | } |
| | | |
| | | //监听 |
| | | @Override |
| | | public void onNext() { |
| | | if (mCurrentPosition >= mVideoInfo.getVideoDetailList().size() - 1) { |
| | | Toast.makeText(getContext(), "没有下一集了", Toast.LENGTH_SHORT).show(); |
| | | return; |
| | | } |
| | | |
| | | selectEpisode(mCurrentPosition + 1, null); |
| | | } |
| | | |
| | | @Override |
| | | public void onBack() {//返回 |
| | | if (getActivity().getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { |
| | | getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | } else {//结束 |
| | | getActivity().finish(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoPause() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoPlay() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void changeDefinition(int p, VideoDefinition definition) { |
| | | Toast.makeText(BeibeiVideoApplication.application, "正在切换清晰度", Toast.LENGTH_SHORT).show(); |
| | | if (mVideoPlayer != null && mVideoPlayer.isPlaying()) |
| | | position = mVideoPlayer.getCurrentPosition(); |
| | | mFunshionIVideoPlayer.changeDefinition(mFSVideoReqData.getUniqueID(), mDefinitions.get(p)); |
| | | } |
| | | |
| | | @Override |
| | | public void selectEpisode(int p, VideoEpisode episode) { |
| | | //选集 |
| | | final FunshionPlayInfo playInfo = new FunshionPlayInfo(); |
| | | playInfo.setVideoInfo(mVideoInfo); |
| | | playInfo.setPosition(p); |
| | | playInfo.setCollected(collected); |
| | | VideoDetailInfo detailInfo = mVideoInfo.getVideoDetailList().get(p); |
| | | String uid = UserUtil.getUid(BeibeiVideoApplication.application); |
| | | BeibeiVideoAPI.getPlayUrl(BeibeiVideoApplication.application, uid, detailInfo.getType(), mVideoInfo.getId(), |
| | | detailInfo.getId(), videoResource.getId(), detailInfo.geteId(), |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | VideoResource resource = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONObject("Resource") |
| | | .toString(), |
| | | new TypeToken<VideoResource>() { |
| | | }.getType()); |
| | | PlayUrl info = new PlayUrl(); |
| | | info.setResource(resource); |
| | | info.setPlayType(Integer.parseInt(jsonObject |
| | | .getJSONObject("Data") |
| | | .optString("PlayType"))); |
| | | info.setUrl(jsonObject.getJSONObject("Data") |
| | | .optString("Url")); |
| | | info.setParams(jsonObject.getJSONObject("Data") |
| | | .optString("Params")); |
| | | playInfo.setPlayUrl(info); |
| | | EventBus.getDefault().post(playInfo); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void collect(boolean collect) { |
| | | |
| | | } |
| | | |
| | | |
| | | } |