1708 lines
75 KiB
Java
1708 lines
75 KiB
Java
package cn.shangyu.gdxzExpert.polyvplayer;
|
|
|
|
import static cn.shangyu.gdxzExpert.ecdemo.common.utils.CommomUtil.simpleDateFormat;
|
|
import static cn.shangyu.gdxzExpert.polyvplayer.util.PolyvNetworkUtils.isConnected;
|
|
import static cn.shangyu.gdxzExpert.utils.DateUtil.getTimeSpan;
|
|
import static cn.shangyu.gdxzExpert.utils.StaUtil.EXPERT_CLASS_QUALITY_DETAILS;
|
|
import static cn.shangyu.gdxzExpert.utils.StaUtil.EXPERT_CLASS_QUALITY_PAY;
|
|
import static cn.shangyu.gdxzExpert.utils.StringUtil.fenGetYuanFormat;
|
|
import static cn.shangyu.gdxzExpert.utils.Url.weurl;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Intent;
|
|
import android.content.res.Configuration;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Color;
|
|
import android.graphics.Paint;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Message;
|
|
import android.os.PowerManager;
|
|
import android.text.TextUtils;
|
|
import android.view.KeyEvent;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.ViewTreeObserver;
|
|
import android.view.WindowManager;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageButton;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.Toast;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.viewpager.widget.ViewPager;
|
|
|
|
import com.easefun.polyvsdk.PolyvBitRate;
|
|
import com.easefun.polyvsdk.PolyvSDKClient;
|
|
import com.easefun.polyvsdk.po.PolyvViewerInfo;
|
|
import com.easefun.polyvsdk.srt.PolyvSRTItemVO;
|
|
import com.easefun.polyvsdk.video.PolyvPlayErrorReason;
|
|
import com.easefun.polyvsdk.video.PolyvSeekType;
|
|
import com.easefun.polyvsdk.video.PolyvVideoView;
|
|
import com.easefun.polyvsdk.video.auxiliary.PolyvAuxiliaryVideoView;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnAdvertisementCountDownListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnAdvertisementEventListener2;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnAdvertisementOutListener2;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnChangeModeListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnGestureClickListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnGestureLeftDownListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnGestureLeftUpListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnGestureRightDownListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnGestureRightUpListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnGestureSwipeLeftListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnGestureSwipeRightListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnPreloadPlayListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnPreparedListener2;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnTeaserCountDownListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnTeaserOutListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnVideoPlayErrorListener2;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnVideoSRTListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnVideoSRTPreparedListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnVideoStatusListener;
|
|
import com.easefun.polyvsdk.video.listener.IPolyvOnVideoTimeoutListener;
|
|
import com.easefun.polyvsdk.vo.PolyvADMatterVO;
|
|
import com.easefun.polyvsdk.vo.PolyvVideoVO;
|
|
import com.google.android.material.appbar.AppBarLayout;
|
|
import com.google.android.material.tabs.TabLayout;
|
|
import com.google.gson.Gson;
|
|
import com.gyf.immersionbar.ImmersionBar;
|
|
import com.lidroid.xutils.exception.HttpException;
|
|
import com.lidroid.xutils.http.ResponseInfo;
|
|
import com.lidroid.xutils.http.callback.RequestCallBack;
|
|
import com.lidroid.xutils.http.client.HttpRequest;
|
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
import com.umeng.analytics.MobclickAgent;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.Serializable;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import cn.shangyu.gdxzExpert.R;
|
|
import cn.shangyu.gdxzExpert.application.BaseApplication;
|
|
import cn.shangyu.gdxzExpert.activity.EvaluateActivity;
|
|
import cn.shangyu.gdxzExpert.activity.PayClassActivity;
|
|
import cn.shangyu.gdxzExpert.adapter.BaseFragemetAdapter;
|
|
import cn.shangyu.gdxzExpert.bean.ClassDetailBean;
|
|
import cn.shangyu.gdxzExpert.bean.TimestampBean;
|
|
import cn.shangyu.gdxzExpert.cast.PolyvScreencastManager;
|
|
import cn.shangyu.gdxzExpert.cast.widget.PolyvScreencastSearchLayout;
|
|
import cn.shangyu.gdxzExpert.cast.widget.PolyvScreencastStatusLayout;
|
|
import cn.shangyu.gdxzExpert.fragment.IntroduceClassFragment;
|
|
import cn.shangyu.gdxzExpert.fragment.IntroduceDetailFragment;
|
|
import cn.shangyu.gdxzExpert.fragment.IntroduceEvaluateFragment;
|
|
import cn.shangyu.gdxzExpert.http.HttpHelper;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.player.PolyvPlayerAudioCoverView;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.player.PolyvPlayerAuxiliaryView;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.player.PolyvPlayerLightView;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.player.PolyvPlayerMediaController;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.player.PolyvPlayerPreviewView;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.player.PolyvPlayerProgressView;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.player.PolyvPlayerVolumeView;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.ppt.PolyvPPTView;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.ppt.PolyvViceScreenLayout;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvErrorMessageUtils;
|
|
import cn.shangyu.gdxzExpert.polyvplayer.util.PolyvScreenUtils;
|
|
import cn.shangyu.gdxzExpert.report.CommUtil;
|
|
import cn.shangyu.gdxzExpert.report.ReportService;
|
|
import cn.shangyu.gdxzExpert.report.reportBean;
|
|
import cn.shangyu.gdxzExpert.ui.CustomProgressDialog;
|
|
import cn.shangyu.gdxzExpert.utils.Constant;
|
|
import cn.shangyu.gdxzExpert.utils.DialogUtil;
|
|
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
|
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
|
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
|
import cn.shangyu.gdxzExpert.utils.ShareUtils;
|
|
import cn.shangyu.gdxzExpert.utils.SignUtil;
|
|
import cn.shangyu.gdxzExpert.utils.StreamTool;
|
|
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
|
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
|
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
|
import cn.shangyu.gdxzExpert.utils.UpdateVersionUtils;
|
|
import cn.shangyu.gdxzExpert.utils.Url;
|
|
import cn.shangyu.gdxzExpert.widget.SnapUpCountDownTimerView;
|
|
import io.dcloud.feature.sdk.Interface.IUniMP;
|
|
|
|
import static cn.shangyu.gdxzExpert.utils.Constant.uniapp_mp_appid;
|
|
|
|
public class CourseDetailPolyvPlayerActivity extends AppCompatActivity implements View.OnClickListener, IntroduceDetailFragment.ChooseListener {
|
|
private static final String EXTRA_FROM_UNIMP_GO_COURSE_DETAIL = "from_unimp_go_course_detail";
|
|
private FrameLayout head;
|
|
/**
|
|
* 视频控制栏
|
|
*/
|
|
private PolyvPlayerMediaController mediaController = null;
|
|
/**
|
|
* 播放器的parentView
|
|
*/
|
|
private RelativeLayout viewLayout = null;
|
|
/**
|
|
* 播放主视频播放器
|
|
*/
|
|
private PolyvVideoView videoView = null;
|
|
|
|
/**
|
|
* 用于播放广告片头的播放器
|
|
*/
|
|
private PolyvAuxiliaryVideoView auxiliaryVideoView = null;
|
|
/**
|
|
* 视频广告,视频片头加载缓冲视图
|
|
*/
|
|
private ProgressBar auxiliaryLoadingProgress = null;
|
|
/**
|
|
* 图片广告界面
|
|
*/
|
|
private PolyvPlayerAuxiliaryView auxiliaryView = null;
|
|
/**
|
|
* 音频模式下的封面
|
|
*/
|
|
private PolyvPlayerAudioCoverView coverView = null;
|
|
//mp3源文件播放时的封面图
|
|
private PolyvPlayerAudioCoverView audioSourceCoverView = null;
|
|
/**
|
|
* 字幕文本视图
|
|
*/
|
|
private TextView srtTextView = null;
|
|
private TextView topSrtTextView = null;
|
|
/**
|
|
* 手势出现的亮度界面
|
|
*/
|
|
private PolyvPlayerLightView lightView = null;
|
|
/**
|
|
* 手势出现的音量界面
|
|
*/
|
|
private PolyvPlayerVolumeView volumeView = null;
|
|
/**
|
|
* 手势出现的进度界面
|
|
*/
|
|
private PolyvPlayerProgressView progressView = null;
|
|
/**
|
|
* 视频加载缓冲视图
|
|
*/
|
|
private ProgressBar loadingProgress = null;
|
|
/**
|
|
* 广告倒计时
|
|
*/
|
|
private TextView advertCountDown = null;
|
|
/**
|
|
* 缩略图界面
|
|
*/
|
|
private PolyvPlayerPreviewView firstStartView = null;
|
|
private ImageView iv_screencast_search,iv_screencast_search_land;
|
|
private LinearLayout videoErrorLayout;
|
|
private TextView videoErrorContent,videoErrorRetry;
|
|
private TextView tv_exchange1,mTitle;
|
|
private PowerManager powerManager;
|
|
private PowerManager.WakeLock wakeLock;
|
|
private int fastForwardPos = 0;
|
|
private ImageView top_back;
|
|
|
|
public static final int GETDETAIL = 101;
|
|
private String excellentcourse_id,opencontents,openid,pinglun;//课程id,二级目录,id,评论
|
|
private String vid,comment_num;
|
|
private TabLayout tabs;
|
|
private String[] mTitles={"课程介绍","课程目录","评价"};
|
|
private ArrayList<Fragment> fgs=new ArrayList<Fragment>();
|
|
private ViewPager viewpager;
|
|
public TextView tv_name,tv_d,tp_yh,tv_pr,tv_ppr,im_yuan,tv_e,tv_tian;
|
|
private String descs;
|
|
public String type="0";
|
|
private String isbuy="0";
|
|
RelativeLayout r_yh,r_buy,r_e;
|
|
private SnapUpCountDownTimerView rushBuyCountDownTimerView;
|
|
AppBarLayout appBarLayout;
|
|
public String starnum;
|
|
LinearLayout l_t;
|
|
TextView tv_type,tv_texs;
|
|
private boolean isPlay = false;
|
|
|
|
// private boolean isBackgroundPlay = true;
|
|
private boolean isBackgroundPlay = false ;
|
|
private String vid1;
|
|
private BaseFragemetAdapter adapter;
|
|
private ImageButton top_right_search;
|
|
//投屏相关
|
|
private PolyvScreencastManager screencastManager;
|
|
private PolyvScreencastStatusLayout fl_screencast_status;
|
|
private PolyvScreencastSearchLayout fl_screencast_search, fl_screencast_search_land;
|
|
// private ServiceConnection playConnection;
|
|
// private PolyvBackgroundPlayService.PlayBinder playBinder;
|
|
//ppt
|
|
private PolyvViceScreenLayout viceScreenLayout;
|
|
private boolean isCalledStopOnPipModeChanged = false;
|
|
private boolean isOnBackKeyPressed;
|
|
private boolean fromUniMpGoCourseDetail = false;
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
|
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(head).init();
|
|
setContentView(R.layout.activity_course_detail_polyv_player);
|
|
MobclickAgent.onEvent(CourseDetailPolyvPlayerActivity.this,EXPERT_CLASS_QUALITY_DETAILS);
|
|
excellentcourse_id=getIntent().getStringExtra("excellentcourse_id");
|
|
opencontents=getIntent().getStringExtra("opencontents");
|
|
openid=getIntent().getStringExtra("openid");
|
|
pinglun=getIntent().getStringExtra("pinglun");
|
|
fromUniMpGoCourseDetail = getIntent().getBooleanExtra(EXTRA_FROM_UNIMP_GO_COURSE_DETAIL, false);
|
|
initnormalview();
|
|
initPolyview();
|
|
initView();
|
|
initScreencast();
|
|
initOnClick();
|
|
boolean isConnected = isConnected(CourseDetailPolyvPlayerActivity.this);
|
|
if (isConnected){//联网正常执行
|
|
|
|
videoDetail(excellentcourse_id);
|
|
}else{//没联网
|
|
ToastUtil.showMessage("无网络,请检查网络连接!");
|
|
}
|
|
|
|
// PolyvBackgroundPlayService.bindService(this, playConnection = new ServiceConnection() {
|
|
// @Override
|
|
// public void onServiceConnected(ComponentName name, IBinder service) {
|
|
// playBinder = (PolyvBackgroundPlayService.PlayBinder) service;
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void onServiceDisconnected(ComponentName name) {
|
|
// }
|
|
// });
|
|
|
|
}
|
|
private boolean isInPictureInPictureMode;
|
|
private BroadcastReceiver pipReceiver;
|
|
private PolyvPPTView pptView;
|
|
ViewTreeObserver.OnGlobalLayoutListener videoviewChange = new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
@Override
|
|
public void onGlobalLayout() {
|
|
resetVideoHeight();
|
|
}
|
|
};
|
|
|
|
//添加副屏布局
|
|
private void addViceScreenLayout(final PolyvVideoView videoView) {
|
|
videoView.post(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
//添加副屏布局
|
|
viceScreenLayout = PolyvViceScreenLayout.addViceLayoutInWindow(CourseDetailPolyvPlayerActivity.this, videoView.getBottom());
|
|
mediaController.setPPTLayout(viceScreenLayout);
|
|
//添加ppt布局
|
|
pptView = new PolyvPPTView(CourseDetailPolyvPlayerActivity.this);
|
|
viceScreenLayout.addView(pptView);
|
|
viceScreenLayout.bindView(videoView, pptView);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 修复小米8中开启画中画后,控件高度没有适应变化问题
|
|
*/
|
|
@SuppressLint("NewApi")
|
|
private void resetVideoHeight() {
|
|
//onCreate中初始化了高度,PolyvScreenUtils.generateHeight16_9(this);
|
|
//如果高度相同,则画中画高度没有成功缩小
|
|
if (viewLayout.getHeight() == PolyvScreenUtils.getHeight16_9() && isInPipMode()) {
|
|
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) viewLayout.getLayoutParams();
|
|
params.height = LinearLayout.LayoutParams.MATCH_PARENT;
|
|
viewLayout.setLayoutParams(params);
|
|
}
|
|
}
|
|
private boolean isInPipMode() {
|
|
if (Build.VERSION.SDK_INT >= 26) {
|
|
return isInPictureInPictureMode();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// @Override
|
|
// public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
|
|
//
|
|
// super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
|
|
// this.isInPictureInPictureMode = isInPictureInPictureMode;
|
|
// if (isInPictureInPictureMode) {
|
|
// // Starts receiving events from action items in PiP mode.
|
|
// pipReceiver = new BroadcastReceiver() {
|
|
// @Override
|
|
// public void onReceive(Context context, Intent intent) {
|
|
// if (intent == null
|
|
// || !"media_control".equals(intent.getAction())
|
|
// || !(videoView.isInPlaybackState() || videoView.isExceptionCompleted())) {
|
|
// return;
|
|
// }
|
|
//
|
|
//
|
|
// final int controlType = intent.getIntExtra("control_type", 0);
|
|
// switch (controlType) {
|
|
// case 1:
|
|
// videoView.start();
|
|
// break;
|
|
// case 2:
|
|
// videoView.pause();
|
|
// break;
|
|
// }
|
|
// }
|
|
// };
|
|
// viewLayout.getViewTreeObserver().addOnGlobalLayoutListener(videoviewChange);
|
|
// registerReceiver(pipReceiver, new IntentFilter("media_control"));
|
|
//// if (playBinder != null) {
|
|
//// Log.d("gdxzplayBinder","正在小窗播放视频");
|
|
//// playBinder.start("正在小窗播放视频", "点击进入播放页面", R.mipmap.ic_launcher);
|
|
//// }
|
|
// } else {
|
|
// // We are out of PiP mode. We can stop receiving events from it.
|
|
// if (pipReceiver != null) {
|
|
// unregisterReceiver(pipReceiver);
|
|
// pipReceiver = null;
|
|
// }
|
|
// if (mediaController.isViceHideInPipMode()) {
|
|
// viceScreenLayout.show();
|
|
// }
|
|
//// if (playBinder != null) {
|
|
//// playBinder.stop();
|
|
//// }
|
|
//
|
|
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
// viewLayout.getViewTreeObserver().removeOnGlobalLayoutListener(videoviewChange);
|
|
// }
|
|
// }
|
|
// if (isCalledStopOnPipModeChanged && !isInPictureInPictureMode) {
|
|
// finish();
|
|
// }
|
|
// }
|
|
|
|
@Override
|
|
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
|
super.onConfigurationChanged(newConfig);
|
|
if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE)
|
|
{
|
|
|
|
if(mediaController!=null)
|
|
{
|
|
|
|
if(mediaController.iv_land.getVisibility()==View.VISIBLE)
|
|
{
|
|
mediaController.changeToLandscape();
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(mediaController!=null)
|
|
{
|
|
|
|
if(mediaController.iv_port.getVisibility()==View.VISIBLE)
|
|
{
|
|
mediaController.changeToPortrait();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
@Override
|
|
protected void onResume() {
|
|
super.onResume();
|
|
|
|
// if (!isInPipMode()) {
|
|
// if (!isBackgroundPlay) {
|
|
// //回来后继续播放
|
|
// if (isPlay) {
|
|
// videoView.onActivityResume();
|
|
// if (auxiliaryView.isPauseAdvert()) {
|
|
// auxiliaryView.hide();
|
|
// }
|
|
// }
|
|
// }
|
|
// else if (playBinder != null) {
|
|
// playBinder.stop();
|
|
// }
|
|
// }
|
|
// mediaController.resume();
|
|
if (!isBackgroundPlay) {
|
|
//回来后继续播放
|
|
if (isPlay) {
|
|
videoView.onActivityResume();
|
|
if (auxiliaryView.isPauseAdvert()) {
|
|
auxiliaryView.hide();
|
|
}
|
|
}
|
|
}
|
|
mediaController.resume();
|
|
|
|
}
|
|
private void initScreencast() {
|
|
fl_screencast_status.setScreencastSearchLayout(fl_screencast_search);
|
|
fl_screencast_status.setLandScreencastSearchLayout(fl_screencast_search_land);
|
|
fl_screencast_status.setVideoView(videoView);
|
|
fl_screencast_status.setMediaController(mediaController);
|
|
|
|
screencastManager = PolyvScreencastManager.getInstance(null);//如果之前已经初始化,那么这里可以传null
|
|
fl_screencast_search.setScreencastStatusLayout(fl_screencast_status);
|
|
fl_screencast_search.setScreencastManager(screencastManager);
|
|
fl_screencast_search_land.setScreencastStatusLayout(fl_screencast_status);
|
|
fl_screencast_search_land.setScreencastManager(screencastManager);
|
|
|
|
iv_screencast_search.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
if (iv_screencast_search.isSelected()) {
|
|
fl_screencast_search.hide(true);
|
|
} else {
|
|
fl_screencast_search.show();
|
|
}
|
|
}
|
|
});
|
|
iv_screencast_search_land.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
fl_screencast_search_land.show();
|
|
}
|
|
});
|
|
|
|
fl_screencast_search.setOnVisibilityChangedListener(new PolyvScreencastSearchLayout.OnVisibilityChangedListener() {
|
|
@Override
|
|
public void onVisibilityChanged(@NonNull View changedView, int visibility) {
|
|
iv_screencast_search.setSelected(visibility == View.VISIBLE);
|
|
}
|
|
});
|
|
}
|
|
private void initOnClick() {
|
|
top_back.setOnClickListener(this);
|
|
tv_exchange1.setOnClickListener(this);
|
|
top_right_search.setOnClickListener(this);
|
|
}
|
|
private void initnormalview()
|
|
{
|
|
rushBuyCountDownTimerView = (SnapUpCountDownTimerView) findViewById(R.id.rushtimerView);
|
|
tabs=findViewById(R.id.tabs);
|
|
top_right_search=findViewById(R.id.top_right_search);
|
|
viewpager=findViewById(R.id.viewpager);
|
|
tv_name=findViewById(R.id.tv_name);
|
|
tv_d=findViewById(R.id.tv_d);
|
|
r_yh=findViewById(R.id.r_yh);
|
|
tp_yh=findViewById(R.id.tp_yh);
|
|
tv_pr=findViewById(R.id.tv_pr);
|
|
tv_ppr=findViewById(R.id.tv_ppr);
|
|
r_buy=findViewById(R.id.r_buy);
|
|
r_buy.setOnClickListener(this);
|
|
r_buy.setEnabled(false);
|
|
im_yuan=findViewById(R.id.im_yuan);
|
|
tv_tian=findViewById(R.id.tv_tian);
|
|
r_e=findViewById(R.id.r_e);
|
|
tv_e=findViewById(R.id.tv_e);
|
|
l_t=findViewById(R.id.l_t);
|
|
tv_type=findViewById(R.id.tv_type);
|
|
tv_texs=findViewById(R.id.tv_texs);
|
|
appBarLayout=findViewById(R.id.appBarLayout);
|
|
r_e.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
if (!UIUtils.checkLoginAndJump(CourseDetailPolyvPlayerActivity.this)) {
|
|
return;
|
|
}
|
|
Intent intent=new Intent(CourseDetailPolyvPlayerActivity.this, EvaluateActivity.class);
|
|
intent.putExtra("excellentcourse_id",excellentcourse_id);
|
|
intent.putExtra("p_id","");
|
|
intent.putExtra("type",type);
|
|
intent.putExtra("starnum",starnum);
|
|
startActivityForResult(intent,301);
|
|
}
|
|
});
|
|
|
|
}
|
|
private void initMenus(){
|
|
|
|
fgs.clear();
|
|
fgs.add(IntroduceClassFragment.newInstance(descs));
|
|
fgs.add(IntroduceDetailFragment.newInstance(excellentcourse_first_title_list,opencontents,openid,isbuy));
|
|
fgs.add(IntroduceEvaluateFragment.newInstance(excellentcourse_id,type,isbuy,starnum,comment_num));
|
|
tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
|
@Override
|
|
public void onTabSelected(TabLayout.Tab tab) {
|
|
tab.setCustomView(R.layout.custrom_tab);
|
|
TextView textView =tab.getCustomView().findViewById(R.id.t_tab);
|
|
textView.setText(tab.getText());
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onTabUnselected(TabLayout.Tab tab) {
|
|
tab.setCustomView(null);
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onTabReselected(TabLayout.Tab tab) {
|
|
|
|
}
|
|
});
|
|
adapter=new BaseFragemetAdapter(
|
|
getSupportFragmentManager());
|
|
if(StringUtil.isEmpty(comment_num)||Integer.valueOf(comment_num)<1)
|
|
{
|
|
mTitles[2]="评价";
|
|
}
|
|
else
|
|
{
|
|
mTitles[2]="评价("+comment_num+")";
|
|
}
|
|
|
|
adapter.setFgs(fgs,mTitles);
|
|
viewpager.setAdapter(adapter);
|
|
tabs.setupWithViewPager(viewpager);
|
|
|
|
if(!StringUtil.isEmpty(opencontents))
|
|
{
|
|
appBarLayout.setExpanded(false, true);
|
|
viewpager.setCurrentItem(1);
|
|
}
|
|
else if("yes".equals(pinglun))
|
|
{
|
|
appBarLayout.setExpanded(false, true);
|
|
viewpager.setCurrentItem(2);
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
private void initPolyview()
|
|
{
|
|
PolyvScreenUtils.generateHeight16_9(this);
|
|
head = findViewById(R.id.head);
|
|
|
|
top_back = (ImageView) findViewById(R.id.top_back);
|
|
mTitle = (TextView) this.findViewById(R.id.top_title);
|
|
|
|
|
|
mediaController = (PolyvPlayerMediaController) findViewById(R.id.polyv_player_media_controller);
|
|
iv_screencast_search = (ImageView) mediaController.findViewById(R.id.iv_screencast_search);
|
|
iv_screencast_search_land = (ImageView) mediaController.findViewById(R.id.iv_screencast_search_land);
|
|
fl_screencast_search = (PolyvScreencastSearchLayout) findViewById(R.id.fl_screencast_search);
|
|
fl_screencast_search_land = (PolyvScreencastSearchLayout) findViewById(R.id.fl_screencast_search_land);
|
|
fl_screencast_status = (PolyvScreencastStatusLayout) findViewById(R.id.fl_screencast_status);
|
|
iv_screencast_search.setVisibility(View.GONE);
|
|
iv_screencast_search_land.setVisibility(View.GONE);//关闭投屏因为课程目录那里点击下一个投屏不会自动投屏到下一个
|
|
viewLayout = (RelativeLayout) findViewById(R.id.view_layout);
|
|
videoView = (PolyvVideoView) findViewById(R.id.polyv_video_view);
|
|
coverView = (PolyvPlayerAudioCoverView) findViewById(R.id.polyv_cover_view);
|
|
audioSourceCoverView = (PolyvPlayerAudioCoverView) findViewById(R.id.polyv_source_audio_cover);
|
|
srtTextView = (TextView) findViewById(R.id.srt);
|
|
topSrtTextView = (TextView) findViewById(R.id.top_srt);
|
|
lightView = (PolyvPlayerLightView) findViewById(R.id.polyv_player_light_view);
|
|
volumeView = (PolyvPlayerVolumeView) findViewById(R.id.polyv_player_volume_view);
|
|
progressView = (PolyvPlayerProgressView) findViewById(R.id.polyv_player_progress_view);
|
|
loadingProgress = (ProgressBar) findViewById(R.id.loading_progress);
|
|
auxiliaryVideoView = (PolyvAuxiliaryVideoView) findViewById(R.id.polyv_auxiliary_video_view);
|
|
auxiliaryLoadingProgress = (ProgressBar) findViewById(R.id.auxiliary_loading_progress);
|
|
auxiliaryView = (PolyvPlayerAuxiliaryView) findViewById(R.id.polyv_player_auxiliary_view);
|
|
advertCountDown = (TextView) findViewById(R.id.count_down);
|
|
firstStartView = (PolyvPlayerPreviewView) findViewById(R.id.polyv_player_first_start_view);
|
|
videoErrorLayout = (LinearLayout) findViewById(R.id.video_error_layout);
|
|
videoErrorContent = (TextView) findViewById(R.id.video_error_content);
|
|
videoErrorRetry = (TextView) findViewById(R.id.video_error_retry);
|
|
tv_exchange1 = (TextView) findViewById(R.id.tv_exchange1);
|
|
// mediaController.initConfig(head, viewLayout, tv_exchange1, 0, 0);
|
|
mediaController.initConfig(head, viewLayout, tv_exchange1, 0, 0);
|
|
mediaController.setAudioCoverView(coverView);
|
|
|
|
auxiliaryVideoView.setPlayerBufferingIndicator(auxiliaryLoadingProgress);
|
|
videoView.setMediaController(mediaController);
|
|
videoView.setPlayerBufferingIndicator(loadingProgress);
|
|
powerManager = (PowerManager)this.getSystemService(this.POWER_SERVICE);
|
|
wakeLock = this.powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "MyClass Lock");
|
|
mTitle.setText("课程详情");
|
|
//添加副屏布局
|
|
addViceScreenLayout(videoView);
|
|
}
|
|
private void initView() {
|
|
videoView.setOpenAd(true);
|
|
videoView.setOpenTeaser(true);
|
|
videoView.setOpenQuestion(true);
|
|
videoView.setOpenSRT(true);
|
|
videoView.setOpenPreload(true, 2);
|
|
videoView.setOpenMarquee(true);
|
|
videoView.setAutoContinue(true);
|
|
videoView.setNeedGestureDetector(true);
|
|
videoView.setSeekType(PolyvSeekType.SEEKTYPE_NORMAL);
|
|
videoView.setLoadTimeoutSecond(25);//加载超时时间,单位:秒
|
|
videoView.setBufferTimeoutSecond(15);//缓冲超时时间,单位:秒
|
|
videoView.disableScreenCAP(this, false);//防录屏开关,true为开启,如果开启防录屏,投屏功能将不可用
|
|
String realName = SharePrefUtil.getString(CourseDetailPolyvPlayerActivity.this, Constant.realName, "肝胆相照专家端app用户");
|
|
vid1=SharePrefUtil.getString(UIUtils.getContext(), Constant.uuid, "")+"_EC_"+excellentcourse_id;
|
|
PolyvViewerInfo polyvViewerInfo = new PolyvViewerInfo();
|
|
// polyvViewerInfo.setViewerId(SharePrefUtil.getString(CourseDetailPolyvPlayerActivity.this, Constant.POLVID, "123"));
|
|
polyvViewerInfo.setViewerId(vid1);
|
|
polyvViewerInfo.setViewerExtraInfo1(SharePrefUtil.getString(UIUtils.getContext(), Constant.uuid, ""));
|
|
polyvViewerInfo.setViewerExtraInfo2(Constant.Report_userId);
|
|
polyvViewerInfo.setViewerName(realName);
|
|
PolyvSDKClient.getInstance().setViewerInfo(polyvViewerInfo);
|
|
// PolyvSDKClient.getInstance().setViewerId(vid1);
|
|
videoView.setOnPreparedListener(new IPolyvOnPreparedListener2() {
|
|
@Override
|
|
public void onPrepared() {
|
|
if (videoView.getVideo() != null && videoView.getVideo().isMp3Source()) {
|
|
audioSourceCoverView.onlyShowCover(videoView);
|
|
} else {
|
|
audioSourceCoverView.hide();
|
|
}
|
|
mediaController.preparedView();
|
|
progressView.setViewMaxValue(videoView.getDuration());
|
|
// 没开预加载在这里开始弹幕
|
|
// danmuFragment.start();
|
|
}
|
|
});
|
|
|
|
videoView.setOnPreloadPlayListener(new IPolyvOnPreloadPlayListener() {
|
|
@Override
|
|
public void onPlay() {
|
|
// 开启预加载在这里开始弹幕
|
|
// danmuFragment.start();
|
|
}
|
|
});
|
|
|
|
|
|
videoView.setOnChangeModeListener(new IPolyvOnChangeModeListener() {
|
|
@Override
|
|
public void onChangeMode(String changedMode) {
|
|
coverView.changeModeFitCover(videoView, changedMode);
|
|
}
|
|
});
|
|
|
|
videoView.setOnVideoTimeoutListener(new IPolyvOnVideoTimeoutListener() {
|
|
@Override
|
|
public void onBufferTimeout(int timeoutSecond, int times) {//在一个缓冲里,每超过设置的timeoutSecond都会回调一次
|
|
Toast.makeText(CourseDetailPolyvPlayerActivity.this, "视频加载速度缓慢,请调整网络", Toast.LENGTH_LONG).show();
|
|
}
|
|
});
|
|
|
|
videoView.setOnVideoStatusListener(new IPolyvOnVideoStatusListener() {
|
|
@Override
|
|
public void onStatus(int status) {
|
|
if (status < 60) {
|
|
Toast.makeText(CourseDetailPolyvPlayerActivity.this, "状态错误 " + status, Toast.LENGTH_SHORT).show();
|
|
} else {
|
|
}
|
|
}
|
|
});
|
|
|
|
videoView.setOnVideoPlayErrorListener(new IPolyvOnVideoPlayErrorListener2() {
|
|
@Override
|
|
public boolean onVideoPlayError(@PolyvPlayErrorReason.PlayErrorReason int playErrorReason) {
|
|
String message = PolyvErrorMessageUtils.getPlayErrorMessage(playErrorReason);
|
|
message += "(error code " + playErrorReason + ")";
|
|
|
|
showErrorView(message);
|
|
return true;
|
|
}
|
|
});
|
|
|
|
//为了能更好的统一错误处理,这个错误回调合并到setOnVideoPlayErrorListener(IPolyvOnVideoPlayErrorListener2)中,对应的错误类型是PolyvPlayErrorReason.VIDEO_ERROR。
|
|
//为了向后兼容,以前的程序不受影响,当设置了这个错误回调时,setOnVideoPlayErrorListener(IPolyvOnVideoPlayErrorListener2)错误回调不会被触发。
|
|
//没有设置这个错误回调时,setOnVideoPlayErrorListener(IPolyvOnVideoPlayErrorListener2)错误回调才会触发。
|
|
// videoView.setOnErrorListener(new IPolyvOnErrorListener2() {
|
|
// @Override
|
|
// public boolean onError() {
|
|
// String message = "当前视频无法播放,请尝试切换网络重新播放或者向管理员反馈(error code " + PolyvPlayErrorReason.VIDEO_ERROR + ")";
|
|
// showErrorView(message);
|
|
// Toast.makeText(PolyvPlayerActivity.this, message, Toast.LENGTH_SHORT).show();
|
|
// return true;
|
|
// }
|
|
// });
|
|
|
|
videoView.setOnAdvertisementOutListener(new IPolyvOnAdvertisementOutListener2() {
|
|
@Override
|
|
public void onOut(@NonNull PolyvADMatterVO adMatter) {
|
|
auxiliaryView.show(adMatter);
|
|
}
|
|
});
|
|
|
|
videoView.setOnAdvertisementCountDownListener(new IPolyvOnAdvertisementCountDownListener() {
|
|
@Override
|
|
public void onCountDown(int num) {
|
|
advertCountDown.setText("广告也精彩:" + num + "秒");
|
|
advertCountDown.setVisibility(View.VISIBLE);
|
|
}
|
|
|
|
@Override
|
|
public void onEnd() {
|
|
advertCountDown.setVisibility(View.GONE);
|
|
auxiliaryView.hide();
|
|
}
|
|
});
|
|
|
|
videoView.setOnAdvertisementEventListener(new IPolyvOnAdvertisementEventListener2() {
|
|
@Override
|
|
public void onShow(PolyvADMatterVO adMatter) {
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onClick(PolyvADMatterVO adMatter) {
|
|
if (!TextUtils.isEmpty(adMatter.getAddrUrl())) {
|
|
try {
|
|
new URL(adMatter.getAddrUrl());
|
|
} catch (MalformedURLException e1) {
|
|
// Log.e(TAG, PolyvSDKUtil.getExceptionFullMessage(e1, -1));
|
|
return;
|
|
}
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
intent.setData(Uri.parse(adMatter.getAddrUrl()));
|
|
startActivity(intent);
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
|
|
videoView.setOnTeaserOutListener(new IPolyvOnTeaserOutListener() {
|
|
@Override
|
|
public void onOut(@NonNull String url) {
|
|
auxiliaryView.show(url);
|
|
}
|
|
});
|
|
|
|
videoView.setOnTeaserCountDownListener(new IPolyvOnTeaserCountDownListener() {
|
|
@Override
|
|
public void onEnd() {
|
|
auxiliaryView.hide();
|
|
}
|
|
});
|
|
|
|
|
|
videoView.setOnVideoSRTPreparedListener(new IPolyvOnVideoSRTPreparedListener() {
|
|
@Override
|
|
public void onVideoSRTPrepared() {
|
|
mediaController.preparedSRT(videoView);
|
|
}
|
|
});
|
|
|
|
videoView.setOnVideoSRTListener(new IPolyvOnVideoSRTListener() {
|
|
@Override
|
|
public void onVideoSRT(@Nullable List<PolyvSRTItemVO> subTitleItems) {
|
|
srtTextView.setText("");
|
|
topSrtTextView.setText("");
|
|
|
|
if (subTitleItems != null) {
|
|
for (PolyvSRTItemVO srtItemVO : subTitleItems) {
|
|
if (srtItemVO.isBottomCenterSubTitle()) {
|
|
srtTextView.setText(srtItemVO.getSubTitle());
|
|
} else if (srtItemVO.isTopCenterSubTitle()) {
|
|
topSrtTextView.setText(srtItemVO.getSubTitle());
|
|
}
|
|
}
|
|
}
|
|
|
|
srtTextView.setVisibility(View.VISIBLE);
|
|
topSrtTextView.setVisibility(View.VISIBLE);
|
|
}
|
|
});
|
|
|
|
videoView.setOnGestureLeftUpListener(new IPolyvOnGestureLeftUpListener() {
|
|
|
|
@Override
|
|
public void callback(boolean start, boolean end) {
|
|
// Log.d(TAG, String.format("LeftUp %b %b brightness %d", start, end, videoView.getBrightness(VideoDetailPolyvPlayerActivity.this)));
|
|
if(mediaController.isLocked()){
|
|
return;
|
|
}
|
|
|
|
int brightness = videoView.getBrightness(CourseDetailPolyvPlayerActivity.this) + 5;
|
|
if (brightness > 100) {
|
|
brightness = 100;
|
|
}
|
|
|
|
videoView.setBrightness(CourseDetailPolyvPlayerActivity.this, brightness);
|
|
lightView.setViewLightValue(brightness, end);
|
|
}
|
|
});
|
|
|
|
videoView.setOnGestureLeftDownListener(new IPolyvOnGestureLeftDownListener() {
|
|
|
|
@Override
|
|
public void callback(boolean start, boolean end) {
|
|
// Log.d(TAG, String.format("LeftDown %b %b brightness %d", start, end, videoView.getBrightness(CourseDetailPolyvPlayerActivity.this)));
|
|
if(mediaController.isLocked()){
|
|
return;
|
|
}
|
|
int brightness = videoView.getBrightness(CourseDetailPolyvPlayerActivity.this) - 5;
|
|
if (brightness < 0) {
|
|
brightness = 0;
|
|
}
|
|
|
|
videoView.setBrightness(CourseDetailPolyvPlayerActivity.this, brightness);
|
|
lightView.setViewLightValue(brightness, end);
|
|
}
|
|
});
|
|
|
|
videoView.setOnGestureRightUpListener(new IPolyvOnGestureRightUpListener() {
|
|
|
|
@Override
|
|
public void callback(boolean start, boolean end) {
|
|
// Log.d(TAG, String.format("RightUp %b %b volume %d", start, end, videoView.getVolume()));
|
|
// 加减单位最小为10,否则无效果
|
|
if(mediaController.isLocked()){
|
|
return;
|
|
}
|
|
int volume = videoView.getVolume() + 10;
|
|
if (volume > 100) {
|
|
volume = 100;
|
|
}
|
|
|
|
videoView.setVolume(volume);
|
|
volumeView.setViewVolumeValue(volume, end);
|
|
}
|
|
});
|
|
|
|
videoView.setOnGestureRightDownListener(new IPolyvOnGestureRightDownListener() {
|
|
|
|
@Override
|
|
public void callback(boolean start, boolean end) {
|
|
// Log.d(TAG, String.format("RightDown %b %b volume %d", start, end, videoView.getVolume()));
|
|
// 加减单位最小为10,否则无效果
|
|
if(mediaController.isLocked()){
|
|
return;
|
|
}
|
|
int volume = videoView.getVolume() - 10;
|
|
if (volume < 0) {
|
|
volume = 0;
|
|
}
|
|
|
|
videoView.setVolume(volume);
|
|
volumeView.setViewVolumeValue(volume, end);
|
|
}
|
|
});
|
|
|
|
videoView.setOnGestureSwipeLeftListener(new IPolyvOnGestureSwipeLeftListener() {
|
|
|
|
@Override
|
|
public void callback(boolean start, int times, boolean end) {
|
|
// 左滑事件
|
|
// Log.d(TAG, String.format("SwipeLeft %b %b", start, end));
|
|
if(mediaController.isLocked()){
|
|
return;
|
|
}
|
|
mediaController.hideTickTips();
|
|
if (fastForwardPos == 0) {
|
|
fastForwardPos = videoView.getCurrentPosition();
|
|
}
|
|
|
|
if (end) {
|
|
if (fastForwardPos < 0)
|
|
fastForwardPos = 0;
|
|
videoView.seekTo(fastForwardPos);
|
|
// danmuFragment.seekTo();
|
|
if (videoView.isCompletedState()) {
|
|
videoView.start();
|
|
// danmuFragment.resume();
|
|
}
|
|
fastForwardPos = 0;
|
|
} else {
|
|
fastForwardPos -= 1000 * times;
|
|
if (fastForwardPos <= 0)
|
|
fastForwardPos = -1;
|
|
}
|
|
progressView.setViewProgressValue(fastForwardPos, videoView.getDuration(), end, false);
|
|
}
|
|
});
|
|
|
|
videoView.setOnGestureSwipeRightListener(new IPolyvOnGestureSwipeRightListener() {
|
|
|
|
@Override
|
|
public void callback(boolean start, int times, boolean end) {
|
|
// 右滑事件
|
|
// Log.d(TAG, String.format("SwipeRight %b %b", start, end));
|
|
if(mediaController.isLocked()){
|
|
return;
|
|
}
|
|
mediaController.hideTickTips();
|
|
if (fastForwardPos == 0) {
|
|
fastForwardPos = videoView.getCurrentPosition();
|
|
}
|
|
|
|
if (end) {
|
|
if (fastForwardPos > videoView.getDuration())
|
|
fastForwardPos = videoView.getDuration();
|
|
if (!videoView.isCompletedState()) {
|
|
videoView.seekTo(fastForwardPos);
|
|
// danmuFragment.seekTo();
|
|
} else if (videoView.isCompletedState() && fastForwardPos != videoView.getDuration()) {
|
|
videoView.seekTo(fastForwardPos);
|
|
// danmuFragment.seekTo();
|
|
videoView.start();
|
|
// danmuFragment.resume();
|
|
}
|
|
fastForwardPos = 0;
|
|
} else {
|
|
fastForwardPos += 1000 * times;
|
|
if (fastForwardPos > videoView.getDuration())
|
|
fastForwardPos = videoView.getDuration();
|
|
}
|
|
progressView.setViewProgressValue(fastForwardPos, videoView.getDuration(), end, true);
|
|
}
|
|
});
|
|
|
|
videoView.setOnGestureClickListener(new IPolyvOnGestureClickListener() {
|
|
@Override
|
|
public void callback(boolean start, boolean end) {
|
|
if (videoView.isInPlaybackState() || videoView.isExceptionCompleted() && mediaController != null)
|
|
if (mediaController.isShowing())
|
|
mediaController.hide();
|
|
else
|
|
mediaController.show();
|
|
}
|
|
});
|
|
|
|
videoErrorRetry.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
videoErrorLayout.setVisibility(View.GONE);
|
|
//调用setVid方法视频会自动播放
|
|
play(vid, PolyvBitRate.ziDong.getNum(), true,false);
|
|
}
|
|
});
|
|
// videoView.setOnPlayPauseListener(new IPolyvOnPlayPauseListener() {
|
|
// @Override
|
|
// public void onPause() {
|
|
// coverView.stopAnimation();
|
|
// mediaController.updatePictureInPictureActions(R.drawable.polyv_btn_play_port, "pause", 1, 1);
|
|
//
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void onPlay() {
|
|
// coverView.startAnimation();
|
|
// mediaController.updatePictureInPictureActions(R.drawable.polyv_btn_pause_port, "start", 2, 2);
|
|
//
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void onCompletion() {
|
|
// coverView.stopAnimation();
|
|
// mediaController.updatePictureInPictureActions(R.drawable.polyv_btn_play_port, "pause", 1, 1);
|
|
//
|
|
// }
|
|
// });
|
|
}
|
|
public void showErrorView(String message){
|
|
videoErrorLayout.setVisibility(View.VISIBLE);
|
|
videoErrorContent.setText(message);
|
|
}
|
|
/**
|
|
* 播放视频
|
|
*
|
|
* @param vid 视频id
|
|
* @param bitrate 码率(清晰度)
|
|
* @param startNow 是否现在开始播放视频
|
|
* @param isMustFromLocal 是否必须从本地(本地缓存的视频)播放
|
|
*/
|
|
public void play(final String vid, final int bitrate, boolean startNow, final boolean isMustFromLocal) {
|
|
|
|
LogUtil.i("vid = "+vid);
|
|
/**每次播放计算播放数+1*/
|
|
// Map<String,String> map = new HashMap<>();
|
|
// map.put("uuid",uuid);
|
|
// HttpMD5SendInfoUtil.sendJsonPostParamNoResultMD5(Url.readSeriesVideo,map);
|
|
|
|
// if (iv_vlms_cover != null && iv_vlms_cover.getVisibility() == View.VISIBLE) {
|
|
// iv_vlms_cover.setVisibility(View.GONE);
|
|
// }
|
|
|
|
|
|
boolean isConnected = isConnected(CourseDetailPolyvPlayerActivity.this);
|
|
if (isConnected){//联网正常执行
|
|
|
|
}else{//没联网
|
|
ToastUtil.showMessage("无网络,请检查网络连接!");
|
|
return;
|
|
}
|
|
if(videoView==null)
|
|
return;
|
|
if (videoView.isDisableScreenCAP()) {
|
|
iv_screencast_search.setVisibility(View.GONE);
|
|
iv_screencast_search_land.setVisibility(View.GONE);
|
|
}
|
|
|
|
videoView.release();
|
|
srtTextView.setVisibility(View.GONE);
|
|
topSrtTextView.setVisibility(View.GONE);
|
|
mediaController.hide();
|
|
mediaController.resetView();
|
|
loadingProgress.setVisibility(View.GONE);
|
|
|
|
auxiliaryVideoView.hide();
|
|
auxiliaryLoadingProgress.setVisibility(View.GONE);
|
|
auxiliaryView.hide();
|
|
advertCountDown.setVisibility(View.GONE);
|
|
firstStartView.hide();
|
|
progressView.resetMaxValue();
|
|
audioSourceCoverView.hide();
|
|
if (StringUtil.isEmpty(vid))
|
|
{
|
|
|
|
firstStartView.show(classDetailBean.getData().getIndex_img(),0);
|
|
return;
|
|
}
|
|
|
|
// danmuFragment.setVid(vid, videoView);
|
|
if (startNow) {
|
|
//调用setVid方法视频会自动播放
|
|
videoView.setVid(vid, bitrate, isMustFromLocal);
|
|
} else {
|
|
//视频不播放,先显示一张缩略图
|
|
firstStartView.setCallback(new PolyvPlayerPreviewView.Callback() {
|
|
|
|
@Override
|
|
public void onClickStart() {
|
|
/**
|
|
* 调用setVid方法视频会自动播放
|
|
* 如果是有学员登陆的播放,可以在登陆的时候通过
|
|
* {@link com.easefun.polyvsdk.PolyvSDKClient.getinstance().setViewerId()}设置学员id
|
|
* 或者调用{@link videoView.setVidWithStudentId}传入学员id进行播放
|
|
*/
|
|
videoView.setVidWithStudentId(vid, bitrate, isMustFromLocal,vid1);
|
|
}
|
|
});
|
|
|
|
firstStartView.show(vid,"");
|
|
}
|
|
if (PolyvVideoVO.MODE_VIDEO.equals(videoView.getPriorityMode())) {
|
|
coverView.hide();
|
|
}
|
|
}
|
|
/**视频详情*/
|
|
private void videoDetail(String excellentcourse_id) {
|
|
|
|
// showProgressDialog("加载中");
|
|
Map<String,String> map = new HashMap<>();
|
|
map.put("excellentcourse_id",excellentcourse_id);
|
|
sendJsonPostParamNoResultMD5(Url.getexcellencourseDetail,map,GETDETAIL);
|
|
}
|
|
CustomProgressDialog dialog;
|
|
public void showProgressDialog(String content) {
|
|
|
|
if (dialog == null) {
|
|
dialog = (CustomProgressDialog) DialogUtil.createProgressDialog(
|
|
this, content);
|
|
} else {
|
|
dialog.setContent(content);
|
|
}
|
|
dialog.show();
|
|
}
|
|
|
|
public ClassDetailBean classDetailBean;
|
|
List<ClassDetailBean.FirstBean> excellentcourse_first_title_list;
|
|
Handler mHandler = new Handler() {
|
|
public void handleMessage(Message msg) {
|
|
if (msg != null) {
|
|
// closeProgressDialog();
|
|
switch (msg.what){
|
|
case GETDETAIL:
|
|
String resultData = (String) msg.obj;
|
|
Gson gson = new Gson();
|
|
classDetailBean=gson.fromJson(resultData,ClassDetailBean.class);
|
|
if ("200".equals(classDetailBean.getCode())&&classDetailBean.getData()!=null)
|
|
{
|
|
needreportDetail("肝胆精品课", classDetailBean.getData().getTags(), classDetailBean.getData().getTitle());
|
|
descs = classDetailBean.getData().getDescs();
|
|
excellentcourse_first_title_list = classDetailBean.getData().getExcellentcourse_first_title_list();
|
|
if(excellentcourse_first_title_list!=null
|
|
&&excellentcourse_first_title_list.size()>0
|
|
) {
|
|
flag: for(ClassDetailBean.FirstBean firstBean:excellentcourse_first_title_list)
|
|
{
|
|
List<ClassDetailBean.SecondBean> secondBeans=firstBean.getExcellentcourse_second_title_list();
|
|
if(secondBeans!=null)
|
|
{
|
|
for(ClassDetailBean.SecondBean secondBean:secondBeans)
|
|
{
|
|
if("0".equals(secondBean.getType()))
|
|
{
|
|
vid =secondBean.getVid();
|
|
break flag;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
isbuy=classDetailBean.getData().getIs_buy();
|
|
tv_name.setText(classDetailBean.getData().getTitle());
|
|
String text1="",text2="",text3="";
|
|
if(!StringUtil.isEmpty(classDetailBean.getData().getStudy_num())&&Integer.valueOf(classDetailBean.getData().getStudy_num())>4)
|
|
{
|
|
text1=classDetailBean.getData().getStudy_num() + "人学" + "•";
|
|
}
|
|
|
|
switch (classDetailBean.getData().getState()) {
|
|
case "1":
|
|
text2="•" + "已完结";
|
|
break;
|
|
case "0":
|
|
text2="•" + "更新"+classDetailBean.getData().getUpload_num()+"节";
|
|
break;
|
|
|
|
} comment_num=classDetailBean.getData().getComment_num();
|
|
type=classDetailBean.getData().getIs_commented();
|
|
r_buy.setEnabled(true);
|
|
|
|
|
|
if("1".equals(isbuy))
|
|
{
|
|
initIntent("",false);
|
|
r_yh.setVisibility(View.GONE);
|
|
r_buy.setVisibility(View.GONE);
|
|
r_e.setVisibility(View.VISIBLE);
|
|
|
|
if("1".equals(type))
|
|
{
|
|
starnum=classDetailBean.getData().getComment_star();
|
|
tv_e.setText("追加评价");
|
|
|
|
}
|
|
else
|
|
{
|
|
tv_e.setText("参与评价有福利");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
initIntent(vid,false);
|
|
r_buy.setVisibility(View.VISIBLE);
|
|
r_e.setVisibility(View.GONE);
|
|
if(!StringUtil.isEmpty(classDetailBean.getData().getDiscount_type()))
|
|
{
|
|
switch (classDetailBean.getData().getDiscount_type())
|
|
{
|
|
case "0":
|
|
im_yuan.setText(fenGetYuanFormat(classDetailBean.getData().getAccount()));
|
|
break;
|
|
case "1":
|
|
r_yh.setVisibility(View.VISIBLE);
|
|
tp_yh.setText("永久优惠");
|
|
tv_pr.setText(fenGetYuanFormat(classDetailBean.getData().getDiscount_price()));
|
|
tv_ppr.setText(fenGetYuanFormat(classDetailBean.getData().getAccount()));
|
|
tv_ppr.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG );
|
|
im_yuan.setText(fenGetYuanFormat(classDetailBean.getData().getDiscount_price()));
|
|
break;
|
|
case "2":
|
|
r_yh.setVisibility(View.VISIBLE);
|
|
tv_pr.setText(fenGetYuanFormat(classDetailBean.getData().getDiscount_price()));
|
|
tv_ppr.setText(fenGetYuanFormat(classDetailBean.getData().getAccount()));
|
|
tv_ppr.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG );
|
|
im_yuan.setText(fenGetYuanFormat(classDetailBean.getData().getDiscount_price()));
|
|
Date date = new Date(System.currentTimeMillis());
|
|
int[]time=getTimeSpan(simpleDateFormat.format(date),classDetailBean.getData().getDiscount_end_date());
|
|
tv_tian.setText(time[0]+"天");
|
|
rushBuyCountDownTimerView.setTime(time[1],time[2],time[3]);
|
|
rushBuyCountDownTimerView.start();
|
|
tp_yh.setText("限时优惠");
|
|
}
|
|
|
|
}
|
|
}
|
|
switch (classDetailBean.getData().getSpecial_type_name()+"") {
|
|
|
|
|
|
case "福利课堂":
|
|
tv_type.setText("福利课堂");
|
|
l_t.setVisibility(View.VISIBLE);
|
|
if(Integer.valueOf(classDetailBean.getData().getFuli_remaining())>0)
|
|
{
|
|
text3= "•"+"福利剩"+classDetailBean.getData().getFuli_remaining()+"份";
|
|
}
|
|
else
|
|
{
|
|
text3= "•"+"福利已发完";
|
|
}
|
|
if("1".equals(isbuy))
|
|
{
|
|
if("0".equals(classDetailBean.getData().getStudy_status()))
|
|
{
|
|
if(Integer.valueOf(classDetailBean.getData().getFuli_remaining())>0)
|
|
{
|
|
tv_texs.setText("先学完先得,奖励"+classDetailBean.getData().getFuli_bon()+"积分");
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
tv_texs.setText("他人抢先,下次趁早学习");
|
|
}
|
|
|
|
tv_texs.setTextColor(Color.parseColor("#999999"));
|
|
}
|
|
else
|
|
{
|
|
if("1".equals(classDetailBean.getData().getIs_granted()))
|
|
{
|
|
|
|
tv_texs.setText("恭喜您学完本课程,"+classDetailBean.getData().getFuli_bon()+"积分福利已发放");
|
|
tv_texs.setTextColor(Color.parseColor("#FD0808"));
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
tv_texs.setText("他人抢先,下次趁早学习");
|
|
tv_texs.setTextColor(Color.parseColor("#999999"));
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(Integer.valueOf(classDetailBean.getData().getFuli_remaining())>0)
|
|
{
|
|
tv_texs.setText("课程学完将奖励"+classDetailBean.getData().getFuli_bon()+"积分");
|
|
}
|
|
else
|
|
{
|
|
r_buy.setVisibility(View.GONE);
|
|
r_e.setVisibility(View.VISIBLE);
|
|
tv_e.setText("本福利课堂已结束");
|
|
r_e.setClickable(false);
|
|
r_e.setBackgroundColor(Color.parseColor("#80000000"));
|
|
|
|
}
|
|
}
|
|
tv_d.setText(text1 + classDetailBean.getData().getVideo_num() + "节课" + text2+text3);
|
|
break;
|
|
case "学完返现":
|
|
tv_type.setText("学完返现");
|
|
if(StringUtil.isEmpty(classDetailBean.getData().getBack_bon())||
|
|
Integer.valueOf(classDetailBean.getData().getBack_bon())<0.1)
|
|
{
|
|
l_t.setVisibility(View.GONE);
|
|
}
|
|
else
|
|
{
|
|
l_t.setVisibility(View.VISIBLE);
|
|
}
|
|
if("0".equals(classDetailBean.getData().getStudy_status()))
|
|
{
|
|
tv_texs.setText("课程学完预期将返还"+classDetailBean.getData().getBack_bon()+"积分");
|
|
tv_texs.setTextColor(Color.parseColor("#999999"));
|
|
}
|
|
else
|
|
{
|
|
tv_texs.setText("恭喜您学完本课程,"+classDetailBean.getData().getBack_bon()+"积分已返还");
|
|
tv_texs.setTextColor(Color.parseColor("#FD0808"));
|
|
}
|
|
// l_t.setVisibility(View.VISIBLE);
|
|
tv_d.setText(text1 + classDetailBean.getData().getVideo_num() + "节课" + text2);
|
|
break;
|
|
default:
|
|
// case "为您推荐":
|
|
// case "精品小课":
|
|
l_t.setVisibility(View.GONE);
|
|
tv_d.setText(text1 + classDetailBean.getData().getVideo_num() + "节课" + text2);
|
|
// break;
|
|
break;
|
|
}
|
|
|
|
|
|
|
|
|
|
initMenus();
|
|
}
|
|
if("1".equals(classDetailBean.getData().getStatus()))
|
|
{
|
|
top_right_search.setVisibility(View.VISIBLE);
|
|
}
|
|
else
|
|
{
|
|
top_right_search.setVisibility(View.GONE);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
ToastUtil.showToast(classDetailBean.getMsg());
|
|
}
|
|
|
|
|
|
break;
|
|
case 0:
|
|
ToastUtil.showToast((String)msg.obj);
|
|
break;
|
|
|
|
|
|
case 404://第一次请求失败
|
|
LogUtil.e("提交失败,重新请求 ");
|
|
videoDetail(excellentcourse_id);
|
|
|
|
break;
|
|
}
|
|
|
|
}
|
|
};
|
|
};
|
|
private void initIntent(String vid,Boolean startNow) {
|
|
|
|
|
|
int playModeCode = getIntent().getIntExtra("playMode", PolyvPlayerActivity.PlayMode.portrait.getCode());
|
|
PolyvPlayerActivity.PlayMode playMode = PolyvPlayerActivity.PlayMode.getPlayMode(playModeCode);
|
|
if (playMode == null)
|
|
playMode = PolyvPlayerActivity.PlayMode.portrait;
|
|
|
|
int bitrate = getIntent().getIntExtra("bitrate", PolyvBitRate.ziDong.getNum());
|
|
// boolean startNow = getIntent().getBooleanExtra("startNow", false);
|
|
|
|
switch (playMode) {
|
|
case landScape:
|
|
mediaController.changeToLandscape();
|
|
break;
|
|
case portrait:
|
|
mediaController.changeToPortrait();
|
|
break;
|
|
}
|
|
// if (!StringUtil.isEmpty(vid)){
|
|
play(vid, bitrate, startNow, false);
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* closeProgressDialog 关闭加载框 void
|
|
*/
|
|
public void closeProgressDialog() {
|
|
if (dialog != null && dialog.isShowing()) {
|
|
dialog.dismiss();
|
|
}
|
|
}
|
|
|
|
public void sendJsonPostParamNoResultMD5(final String postUrl, final Map<String, String> param,final int callType) {
|
|
|
|
HttpHelper.loadData(HttpRequest.HttpMethod.GET, Url.getTimestamp,null, new RequestCallBack<String>() {
|
|
|
|
@Override
|
|
public void onSuccess(ResponseInfo<String> info) {
|
|
String uuid = SharePrefUtil.getString(UIUtils.getContext(), Constant.uuid, "");
|
|
param.put("user_uuid", uuid);
|
|
TimestampBean bean = GsonTools.fromGsonToBean(info.result, TimestampBean.class);
|
|
param.put("timestamp", bean.getTimestamp());
|
|
param.put("client_type", "A");
|
|
param.put("version", UpdateVersionUtils.getVersionName());
|
|
new Thread() {
|
|
public void run() {
|
|
String encoding = "UTF-8";
|
|
Gson gson = new Gson();
|
|
String params = gson.toJson(param);
|
|
byte[] data;
|
|
try {
|
|
String sign = SignUtil.getSign(param);
|
|
LogUtil.i("params = "+params.toString());
|
|
data = params.getBytes(encoding);
|
|
URL url = new URL(postUrl);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("POST");
|
|
conn.setDoOutput(true);
|
|
conn.setRequestProperty("Content-Type","application/json");
|
|
conn.setRequestProperty("sign",sign);
|
|
conn.setRequestProperty("Content-Length",String.valueOf(data.length));
|
|
conn.setConnectTimeout(5 * 1000);
|
|
OutputStream outStream = conn.getOutputStream();
|
|
outStream.write(data);
|
|
outStream.flush();
|
|
outStream.close();
|
|
int ssss=conn.getResponseCode() ;
|
|
if (ssss == 200) {
|
|
InputStream inStream = conn.getInputStream();
|
|
String result = new String(StreamTool.readInputStream(inStream), "UTF-8");
|
|
String string = new String(result);
|
|
LogUtil.i("result = "+result);
|
|
JSONObject jsonObject = new JSONObject(string);
|
|
String optString = jsonObject.optString("code");
|
|
String message = jsonObject.optString("message");
|
|
if ("200".equals(optString)||"106".equals(optString)||"1".equals(optString)) {
|
|
Message msg = Message.obtain();
|
|
msg.what = callType;
|
|
msg.obj = result;
|
|
mHandler.sendMessage(msg);
|
|
}else {
|
|
mHandler.sendEmptyMessage(0);
|
|
}
|
|
}else {
|
|
mHandler.sendEmptyMessage(0);
|
|
}
|
|
} catch (Exception e) {
|
|
LogUtil.e("提交失败,请重试 = "+e.getMessage());
|
|
mHandler.sendEmptyMessage(404);
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
|
|
}
|
|
}
|
|
}.start();
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(HttpException arg0, String arg1) {
|
|
closeProgressDialog();
|
|
}
|
|
});
|
|
|
|
}
|
|
@Override
|
|
public void onClick(View v) {
|
|
switch (v.getId())
|
|
{
|
|
case R.id.top_right_search:
|
|
share();
|
|
needreportSome("share","","");
|
|
break;
|
|
case R.id.top_back:
|
|
handleBackAction();
|
|
break;
|
|
case R.id.r_buy:
|
|
if (!UIUtils.checkLoginAndJump(CourseDetailPolyvPlayerActivity.this)) {
|
|
return;
|
|
}
|
|
MobclickAgent.onEvent(CourseDetailPolyvPlayerActivity.this,EXPERT_CLASS_QUALITY_PAY);
|
|
Intent intent=new Intent(CourseDetailPolyvPlayerActivity.this, PayClassActivity.class);
|
|
intent.putExtra("price",im_yuan.getText().toString());
|
|
intent.putExtra("tags",classDetailBean.getData().getTags());
|
|
intent.putExtra("imgurl",classDetailBean.getData().getIndex_img());
|
|
intent.putExtra("title",tv_name.getText().toString());
|
|
intent.putExtra("excellencourse_id",excellentcourse_id);
|
|
startActivity(intent);
|
|
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
private void handleBackAction() {
|
|
if (fromUniMpGoCourseDetail) {
|
|
IUniMP uniappMP = BaseApplication.getUniMPCaches().get(uniapp_mp_appid);
|
|
if (uniappMP != null && uniappMP.isRunning()) {
|
|
uniappMP.showUniMP();
|
|
}
|
|
}
|
|
finish();
|
|
}
|
|
|
|
|
|
@Override
|
|
protected void onStop() {
|
|
super.onStop();
|
|
if (!isBackgroundPlay) {
|
|
//弹出去暂停
|
|
isPlay = videoView.onActivityStop();
|
|
|
|
}
|
|
// isCalledStopOnPipModeChanged = isInPipMode();
|
|
// mediaController.pause();
|
|
// if (!isInPipMode()) {
|
|
// if (!isBackgroundPlay || isInPictureInPictureMode) {
|
|
// //弹出去暂停
|
|
// isPlay = videoView.onActivityStop();
|
|
// }
|
|
//// else if (playBinder != null && !isOnBackKeyPressed) {
|
|
//// playBinder.start("正在后台播放视频", "点击进入播放页面", R.mipmap.ic_launcher);
|
|
//// }
|
|
// }
|
|
// PolyvScreenUtils.removePIPSingleInstanceTask(this, PolyvPlayerActivity.class.getName(), isInPictureInPictureMode);
|
|
}
|
|
@Override
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
fl_screencast_search.destroy();
|
|
fl_screencast_search_land.destroy();
|
|
screencastManager.release();
|
|
if(rushBuyCountDownTimerView!=null)
|
|
{
|
|
rushBuyCountDownTimerView.stop();
|
|
}
|
|
videoView.destroy();
|
|
videoView = null;
|
|
auxiliaryView.hide();
|
|
firstStartView.hide();
|
|
coverView.hide();
|
|
mediaController.disable();
|
|
if (dialog != null && dialog.isShowing()) {
|
|
dialog.dismiss();
|
|
}
|
|
if (viceScreenLayout != null) {
|
|
viceScreenLayout.destroy();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void chosecourse(String excellentcourse_id,Boolean startnow) {
|
|
initIntent(excellentcourse_id,startnow);
|
|
}
|
|
|
|
@Override
|
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
if(requestCode==301&&data!=null)
|
|
{
|
|
viewpager.setCurrentItem(2);
|
|
adapter.currentFragment.getView().findViewById(R.id.r_notr).setVisibility(View.GONE);;
|
|
starnum = data.getStringExtra("starnum");
|
|
tv_e.setText("追加评价");
|
|
type="1";
|
|
((IntroduceEvaluateFragment) adapter.currentFragment).isAllEva=true;
|
|
((ImageView)adapter.currentFragment.getView().findViewById(R.id.im_eva)).setImageResource(R.drawable.all_eva);
|
|
needreportSome("comment","","");
|
|
}
|
|
}
|
|
/**
|
|
* 调用分享功能
|
|
*/
|
|
private void share() {
|
|
if(classDetailBean==null||classDetailBean.getData()==null)
|
|
{
|
|
return;
|
|
}
|
|
String shareTitle =classDetailBean.getData().getTitle() +"-肝胆精品课";
|
|
String shareUrl = weurl+"excellencourse/index.htm#/courseDetail?excellentcourse_id="+classDetailBean.getData().getId();//测试环境
|
|
// String shareUrl = "https://wx.igandan.com/excellencourse/index.htm#/courseDetail?excellentcourse_id="+classDetailBean.getData().getId();//正式环境
|
|
String msgSinaContent = "肝胆相照®肝胆病在线公共服务平台";
|
|
// ShareUtils.shareMsg(ct, shareTitle, "分享给你一个好看的文章," + shareTitle +
|
|
// " 详情:" + shareUrl, null);
|
|
|
|
|
|
Bitmap bitmap = ImageLoader.getInstance().loadImageSync("http://doc.igandan.com/app/html/img/2016/20160714132557.png");
|
|
ShareUtils.shareUmeng(CourseDetailPolyvPlayerActivity.this, shareTitle, msgSinaContent, msgSinaContent,
|
|
"http://doc.igandan.com/app/html/img/2016/20160714132557.png", shareUrl, bitmap);
|
|
// ShareUtils.mController.openShare(GDEventDetailActivity.this, false);
|
|
}
|
|
@Override
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
if (fl_screencast_search.getVisibility() == View.VISIBLE) {
|
|
fl_screencast_search.hide(true);
|
|
return true;
|
|
}
|
|
if (fl_screencast_search_land.getVisibility() == View.VISIBLE) {
|
|
fl_screencast_search_land.hide(true);
|
|
return true;
|
|
}
|
|
// isOnBackKeyPressed = true;
|
|
|
|
}
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
}
|
|
@Override
|
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
if (hideViewOnTouchOutside(ev, fl_screencast_search_land)) {
|
|
return true;
|
|
}
|
|
// else if (hideViewOnTouchOutside(ev, landPptDirLayout)) {
|
|
// return true;
|
|
// }
|
|
return super.dispatchTouchEvent(ev);
|
|
}
|
|
|
|
private boolean hideViewOnTouchOutside(MotionEvent ev, View view) {
|
|
if (ev.getAction() == MotionEvent.ACTION_DOWN && view.getVisibility() == View.VISIBLE) {
|
|
int[] location = new int[2];
|
|
view.getLocationInWindow(location);
|
|
if (ev.getX() < location[0]) {
|
|
if (view instanceof PolyvScreencastSearchLayout) {
|
|
((PolyvScreencastSearchLayout) view).hide(true);
|
|
} else {
|
|
view.setVisibility(View.GONE);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
public void needreportSome(String name,String page,String tags)
|
|
{
|
|
List<reportBean> reportBeans=new ArrayList<>();
|
|
reportBean rbens=new reportBean();
|
|
rbens.setUser_id(Constant.Report_userId);
|
|
rbens.setApp_key(Constant.Repotr_app_key);
|
|
rbens.setOs(CommUtil.Repotr_os);
|
|
rbens.setDevice(CommUtil.getDeviceName());
|
|
rbens.setDevice_type(CommUtil.getDeviceType());
|
|
rbens.setApp_version(CommUtil.getVersionName());
|
|
rbens.setNetwork_carrier(CommUtil.getCarrierName);
|
|
rbens.setNetwork_type(CommUtil.getCurrentNetworkType(UIUtils.getContext()));
|
|
rbens.setEvent_nickname(name);
|
|
if(classDetailBean!=null&&classDetailBean.getData()!=null)
|
|
{
|
|
rbens.setResource_name( classDetailBean.getData().getTitle());
|
|
rbens.setResource_option(classDetailBean.getData().getTags()+"");
|
|
}
|
|
rbens.setPage_type("肝胆精品课");
|
|
|
|
|
|
rbens.setCreate_date(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
reportBeans.add(rbens);
|
|
startReport(reportBeans);
|
|
}
|
|
public void startReport(List<reportBean> list)
|
|
{
|
|
Intent intent = new Intent(CourseDetailPolyvPlayerActivity.this, ReportService.class);
|
|
if(list!=null)
|
|
{
|
|
intent.putExtra("report_list", (Serializable) list);
|
|
|
|
}
|
|
intent.putExtra("report_token", Constant.Repotr_token);
|
|
|
|
startService(intent);
|
|
}
|
|
public void needreportDetail(String page,String tags,String name)
|
|
{
|
|
List<reportBean> reportBeans=new ArrayList<>();
|
|
reportBean rbens=new reportBean();
|
|
rbens.setUser_id(Constant.Report_userId);
|
|
rbens.setApp_key(Constant.Repotr_app_key);
|
|
rbens.setOs(CommUtil.Repotr_os);
|
|
rbens.setDevice(CommUtil.getDeviceName());
|
|
rbens.setDevice_type(CommUtil.getDeviceType());
|
|
rbens.setApp_version(CommUtil.getVersionName());
|
|
rbens.setNetwork_carrier(CommUtil.getCarrierName);
|
|
rbens.setNetwork_type(CommUtil.getCurrentNetworkType(UIUtils.getContext()));
|
|
rbens.setEvent_nickname("detail_page");
|
|
rbens.setPage_type(page);
|
|
rbens.setResource_name(name);
|
|
rbens.setPage_type(page);
|
|
rbens.setResource_option(tags+"");
|
|
rbens.setCreate_date(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
reportBeans.add(rbens);
|
|
startReport(reportBeans);
|
|
}
|
|
} |