huangxinbao

fix whitebroad delete

... ... @@ -49,4 +49,7 @@ dependencies {
compile 'com.nineoldandroids:library:2.4.0'
compile 'me.yokeyword:fragmentation:0.10.3'
compile files('libs/pldroid-player-1.5.1.jar')
compile 'com.qiniu:happy-dns:0.2.+'
}
... ...
... ... @@ -3,6 +3,7 @@ package com.mang.xdy.demo;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
... ... @@ -12,6 +13,7 @@ import com.mang.xdy.demo.activity.AudioPublisherActivity;
import com.mang.xdy.demo.activity.VideoPlayActivity;
import com.mang.xdy.demo.activity.VideoPublisherActivity;
import com.mang.xdy.demo.bean.JoinClassBean;
import com.mang.xdy.demo.utils.ToastUtil;
import com.mang.xdy.utils.XdyLogUtil;
import butterknife.BindView;
... ... @@ -44,6 +46,9 @@ public class MainActivity extends AppCompatActivity {
@OnClick({R.id.btn_home_enter_class,R.id.btn_home_enter_publisher,R.id.btn_home_enter_publisherAudio})
public void onViewClicked(View view) {
if(TextUtils.isEmpty(joinClass())){
return;
}
switch (view.getId()){
case R.id.btn_home_enter_class:
... ... @@ -63,17 +68,47 @@ public class MainActivity extends AppCompatActivity {
break;
}
}
private String classId="";
private String userRole="";
private String serviceIp="";
private String userId="";
public boolean getLoginInfo(){
classId=edtHomeClassId.getText().toString();
userRole=edtHomeRole.getText().toString();
serviceIp=edtHomeServiceIp.getText().toString();
userId=edtHomeUserId.getText().toString();
if(TextUtils.isEmpty(classId)){
ToastUtil.showToast("课堂Id不能为空",this);
return false;
}
if(TextUtils.isEmpty(serviceIp)){
ToastUtil.showToast("服务器地址不能为空",this);
return false;
}
if(TextUtils.isEmpty(userRole)){
ToastUtil.showToast("角色不能为空",this);
return false;
}
if(TextUtils.isEmpty(userId)){
ToastUtil.showToast("用户id不能为空",this);
return false;
}
return true;
}
public String joinClass(){
JoinClassBean joinClassBean=new JoinClassBean();
joinClassBean.setClassId(Integer.parseInt(edtHomeClassId.getText().toString()));
joinClassBean.setUserRole(edtHomeRole.getText().toString());
joinClassBean.setPortal(edtHomeServiceIp.getText().toString());
joinClassBean.setUserId(Integer.parseInt(edtHomeUserId.getText().toString()));
if(getLoginInfo()) {
JoinClassBean joinClassBean = new JoinClassBean();
joinClassBean.setClassId(Integer.parseInt(classId));
joinClassBean.setUserRole(userRole);
joinClassBean.setPortal(serviceIp);
joinClassBean.setUserId(Integer.parseInt(userId));
joinClassBean.setUserName("");
String joinclass=new Gson().toJson(joinClassBean);
XdyLogUtil.e("init 初始化",joinclass);
String joinclass = new Gson().toJson(joinClassBean);
// XdyLogUtil.e("init 初始化", joinclass);
return joinclass;
}else{
return "";
}
}
}
... ...
package com.mang.xdy.demo.activity;
;
import android.app.Dialog;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
... ... @@ -11,30 +10,29 @@ import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.Gravity;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.JsonNull;
import com.mang.xdy.common.Constants;
import com.mang.xdy.core.SPUtil;
import com.mang.xdy.core.XdySdk;
import com.mang.xdy.demo.R;
import com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter;
import com.mang.xdy.demo.bean.DocEntity;
import com.mang.xdy.demo.bean.ErrorEntity;
import com.mang.xdy.demo.bean.GetDocImageEntity;
import com.mang.xdy.demo.bean.InitClassSuccessEntity;
import com.mang.xdy.demo.bean.JoinClass;
import com.mang.xdy.demo.bean.ResponseEntity;
import com.mang.xdy.demo.bean.VideoOrAudioStopEntity;
import com.mang.xdy.demo.bean.VideoPlayBean;
import com.mang.xdy.demo.utils.JsonUtil;
import com.mang.xdy.demo.utils.ToastUtil;
import com.mang.xdy.demo.widget.dialog.LoginDialog;
... ... @@ -42,19 +40,30 @@ import com.mang.xdy.listener.ObserverListener;
import com.mang.xdy.utils.UIUtils;
import com.mang.xdy.utils.XdyLogUtil;
import com.mang.xdy.utils.XdyStringUtils;
import com.pili.pldroid.player.AVOptions;
import com.pili.pldroid.player.PLMediaPlayer;
import com.pili.pldroid.player.widget.PLVideoTextureView;
import com.pili.pldroid.player.widget.PLVideoView;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Locale;
import butterknife.BindView;
import butterknife.ButterKnife;
import static com.mang.xdy.demo.application.XdyApplicaiton.getActivity;
import static com.pili.pldroid.player.AVOptions.KEY_DELAY_OPTIMIZATION;
public class VideoPlayActivity extends AppCompatActivity implements ObserverListener{
public class VideoPlayActivity extends AppCompatActivity implements ObserverListener, PLMediaPlayer.OnErrorListener, PLMediaPlayer.OnInfoListener {
private final static String TAG = "VideoPlayActivity";
@BindView(R.id.img_playVideo_novideo)
ImageView img_playVideo_novideo;
private String username="";
private String userpwd="";
@BindView(R.id.btn_videoPlay_exit)
Button btn_videoPlay_exit;
private String username = "";
private String userpwd = "";
private SimpleFragmentPagerAdapter pagerAdapter;
private ViewPager viewPager;
private TabLayout tabLayout;
... ... @@ -64,18 +73,22 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
private XdySdk xdySdk;
private LoginDialog mLoginDialog;
private ProgressDialog mProgressDialog;
private Handler mHandler=new Handler(){
@BindView(R.id.img_playVideo_replay)
PLVideoTextureView mVideoView;
//TODO 默认回放
private boolean replay = true;
private Handler mmHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
ResponseEntity responseEntity= (ResponseEntity) msg.obj;
switch (responseEntity.getType()){
ResponseEntity responseEntity = (ResponseEntity) msg.obj;
switch (responseEntity.getType()) {
case Constants.ERROR_CODE:
handError(responseEntity.getType(),responseEntity.getParam());
handError(responseEntity.getType(), responseEntity.getParam());
break;
case Constants.CLASS_INIT_SUCCESS:
String login=responseEntity.getParam();
parseJoinClass(login,true);
String login = responseEntity.getParam();
parseJoinClass(login, true);
ToastUtil.showToastshort("初始化课堂成功", VideoPlayActivity.this);
break;
case Constants.CLASS_JOIN_SUCCESS:
... ... @@ -83,8 +96,8 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
progressDialogDismiss();
UIUtils.closeDialog(mLoginDialog);
ToastUtil.showToastshort("加入课堂成功", VideoPlayActivity.this);
String userJson=responseEntity.getParam();
SPUtil.putString(VideoPlayActivity.this, Constants.CLASS_JOIN_SUCCESS,userJson);
String userJson = responseEntity.getParam();
SPUtil.putString(VideoPlayActivity.this, Constants.CLASS_JOIN_SUCCESS, userJson);
break;
case Constants.VIDEO_PLAY:
//播放视频
... ... @@ -101,19 +114,22 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
stopPlay(responseEntity.getParam());
break;
case "video_success":
//自定义消息 播放视频音频都通过这个来判断
img_playVideo_novideo.setVisibility(View.GONE);
break;
}
}
};
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //屏幕常亮
setContentView(R.layout.activity_video_play);
ButterKnife.bind(this);
xdySdk=XdySdk.getXdyInstance();
XdySdk.init(this);
xdySdk = XdySdk.getXdyInstance();
xdySdk.add(this);
init();
progressDialogShow();
... ... @@ -123,7 +139,36 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
public void init() {
initClass = getIntent().getStringExtra("init");
xdySdk.api("init", initClass);
btn_videoPlay_exit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// xdySdk.api("leaveClass", "");
//
// xdySdk.remove(VideoPlayActivity.this);
// xdySdk.removeAll();
// UIUtils.closeDialog(mLoginDialog);
// VideoPlayActivity.super.onBackPressed();
// Exit();
String id="initRecordPlayback";
String param="{\n" +
" \"classId\": 479270427 ,\n" +
" \"portal\": \"112.126.80.182:90\",\n" +
" \"userRole\": \"normal\",\n" +
" \"userName\": \"\",\n" +
" \"userId\": 0\n" +
"}";
String ss=XdyStringUtils.stringToJson(param,true);
xdySdk.api(id,ss);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
xdySdk.api("startRecordPlayback", "");
}
}, 200);
}
});
}
public void setTablayout() {
... ... @@ -134,14 +179,15 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
tabLayout.setupWithViewPager(viewPager);
tabLayout.setTabMode(TabLayout.MODE_FIXED);
}
//判断解析是否有密码
public void parseJoinClass(String rsponse,boolean isShowPwd){
InitClassSuccessEntity initClassSuccessEntity=JsonUtil.parseJsonToBean(rsponse,InitClassSuccessEntity.class);
if(initClassSuccessEntity!=null) {
public void parseJoinClass(String rsponse, boolean isShowPwd) {
InitClassSuccessEntity initClassSuccessEntity = JsonUtil.parseJsonToBean(rsponse, InitClassSuccessEntity.class);
if (initClassSuccessEntity != null) {
if (initClassSuccessEntity.isPasswordRequired()) {
isShowPwd=true;
isShowPwd = true;
} else {
isShowPwd=false;
isShowPwd = false;
userpwd = "123321";
}
}
... ... @@ -159,40 +205,40 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
progressDialogShow();
}
});
}else if (mLoginDialog != null) {
} else if (mLoginDialog != null) {
UIUtils.closeDialog(mLoginDialog);
}
}
//加入课堂
public void joinClass(String rsponse,boolean isShowPwd) {
JoinClass joinClass=new JoinClass();
public void joinClass(String rsponse, boolean isShowPwd) {
JoinClass joinClass = new JoinClass();
joinClass.setHasCamera(false);
joinClass.setHasMicrophone(false);
joinClass.setUserName(username);
if(!isShowPwd){
if (!isShowPwd) {
joinClass.setPassword("123321");
}else{
} else {
joinClass.setPassword(userpwd);
}
String temp=new Gson().toJson(joinClass);
String temp = new Gson().toJson(joinClass);
String jsonParmp = XdyStringUtils.stringToJson(temp, true);
XdyLogUtil.e("加入课堂", jsonParmp);
xdySdk.api("joinClass", jsonParmp);
}
//加入课堂
public void joinClass(String username,String userpwd,boolean isShowPwd) {
JoinClass joinClass=new JoinClass();
public void joinClass(String username, String userpwd, boolean isShowPwd) {
JoinClass joinClass = new JoinClass();
joinClass.setHasCamera(false);
joinClass.setHasMicrophone(false);
joinClass.setUserName(username);
if(!isShowPwd){
if (!isShowPwd) {
joinClass.setPassword("123321");
}else{
} else {
joinClass.setPassword(userpwd);
}
String temp=new Gson().toJson(joinClass);
String temp = new Gson().toJson(joinClass);
String jsonParmp = XdyStringUtils.stringToJson(temp, true);
XdyLogUtil.e("加入课堂", jsonParmp);
xdySdk.api("joinClass", jsonParmp);
... ... @@ -200,24 +246,26 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
/**
* 播放视频
*
* @param response
*/
public void playVideo(String response) {
xdySdk.api("playVideo", response+"", surfaceviewPlayVideo, VideoPlayActivity.this);
xdySdk.api("playVideo", response + "", surfaceviewPlayVideo, VideoPlayActivity.this);
// img_playVideo_novideo.setVisibility(View.GONE);
img_playVideo_novideo.setImageResource(R.mipmap.no_video);
ToastUtil.showToastshort("视频播放初始化",VideoPlayActivity.this);
ToastUtil.showToastshort("视频播放初始化", VideoPlayActivity.this);
}
/**
* 播放音频
*
* @param response
*/
public void playAudio(String response) {
xdySdk.api("playAudio", response, null, VideoPlayActivity.this);
img_playVideo_novideo.setImageResource(R.mipmap.audio_mode);
img_playVideo_novideo.setVisibility(View.VISIBLE);
ToastUtil.showToastshort("音频播放初始化",VideoPlayActivity.this);
ToastUtil.showToastshort("音频播放初始化", VideoPlayActivity.this);
}
@Override
... ... @@ -235,10 +283,13 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
@Override
public void onClick(DialogInterface dialogInterface, int i) {
xdySdk.onPlayDestroy();
xdySdk.api("leaveClass","");
xdySdk.api("leaveClass", "");
//
// xdySdk.remove(VideoPlayActivity.this);
xdySdk.removeAll();
UIUtils.closeDialog(mLoginDialog);
mHandler.removeCallbacksAndMessages(null);
VideoPlayActivity.super.onBackPressed();
// VideoPlayActivity.super.onBackPressed();
Exit();
}
})
... ... @@ -250,15 +301,16 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
/**
* 错误处理
*
* @param errorId
* @param errorMsg
*/
public void handError(String errorId,String errorMsg){
ErrorEntity errorEntity=JsonUtil.parseJsonToBean(errorMsg,ErrorEntity.class);
if(errorEntity==null){
public void handError(String errorId, String errorMsg) {
ErrorEntity errorEntity = JsonUtil.parseJsonToBean(errorMsg, ErrorEntity.class);
if (errorEntity == null) {
return;
}
switch (errorEntity.getCode()+""){
switch (errorEntity.getCode() + "") {
case "100":
case "101":
case "102":
... ... @@ -276,17 +328,21 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
case "206":
case "207":
case "208":
ToastUtil.showToastshort(errorEntity.getReson(),this);
ToastUtil.showToastshort(errorEntity.getReson(), this);
Exit();
break;
case "300":
case "301":
progressDialogDismiss();
break;
case "10000":
ToastUtil.showToastshort(errorEntity.getReson(),this);
ToastUtil.showToastshort(errorEntity.getReson(), this);
break;
case "10001":
ToastUtil.showToastshort(errorEntity.getReson(),this);
ToastUtil.showToastshort(errorEntity.getReson(), this);
break;
case "20000":
ToastUtil.showToastshort(errorEntity.getReson(),this);
ToastUtil.showToastshort(errorEntity.getReson(), this);
break;
}
... ... @@ -296,34 +352,36 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
/**
* 错误情况退出
*/
public void Exit(){
public void Exit() {
xdySdk.remove(this);
UIUtils.closeDialog(mLoginDialog);
mHandler.removeCallbacksAndMessages(null);
// mmHandler.removeCallbacksAndMessages(null);
this.finish();
}
public void progressDialogDismiss(){
if(mProgressDialog!=null){
public void progressDialogDismiss() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
}
public void progressDialogShow(){
if(mProgressDialog==null){
mProgressDialog=ProgressDialog.show(VideoPlayActivity.this,"","加载中");
}else {
public void progressDialogShow() {
if (mProgressDialog == null) {
mProgressDialog = ProgressDialog.show(VideoPlayActivity.this, "", "加载中");
} else {
mProgressDialog.show();
}
}
/**
* 停止播放
*
* @param response
*/
public void stopPlay(String response){
VideoOrAudioStopEntity entity= JsonUtil.parseJsonToBean(response,VideoOrAudioStopEntity.class);
if(entity!=null) {
if(xdySdk.onPlayStop(entity.getMediaId()+"")){
public void stopPlay(String response) {
VideoOrAudioStopEntity entity = JsonUtil.parseJsonToBean(response, VideoOrAudioStopEntity.class);
if (entity != null) {
if (xdySdk.onPlayStop(entity.getMediaId() + "")) {
img_playVideo_novideo.setImageResource(R.mipmap.novideo);
img_playVideo_novideo.setVisibility(View.VISIBLE);
}
... ... @@ -332,12 +390,221 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
@Override
public void observerUpData(String type, String parameter) {
XdyLogUtil.e(TAG+"observer:",Thread.currentThread().getId()+"");
ResponseEntity responseEntity=new ResponseEntity(type,parameter);
Message message=Message.obtain();
message.obj=responseEntity;
mHandler.sendMessage(message);
XdyLogUtil.e(TAG + "observer:", Thread.currentThread().getId() + "");
ResponseEntity responseEntity = new ResponseEntity(type, parameter);
Message message = Message.obtain();
message.obj = responseEntity;
mmHandler.sendMessage(message);
}
/*************************************** 回放***************************************************/
private static final int FADE_OUT = 1;
private static final int SHOW_PROGRESS = 2;
private TextView mEndTime, mCurrentTime;
private boolean mShowing;
private boolean mDragging;
private RelativeLayout mMediaControllerRight;
// private PLMediaPlayer mMediaPlayer;
private FrameLayout mMediaContainer;
private ImageButton mPauseButton;
private SeekBar mSeekBar;
private RelativeLayout mPauseContainer;
private TextView mClassName;
private SurfaceView mSurfaceView = null;
private AlertDialog mErrorDialog;
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case FADE_OUT:
hideMediaContainer();
break;
case SHOW_PROGRESS:
setProgress();
if (!mDragging && mShowing) {
msg = obtainMessage(SHOW_PROGRESS);
sendMessageDelayed(msg, 1000);
updatePausePlay();
}
break;
}
}
};
public void initReplay() {
mVideoView.setOnInfoListener(this);
mVideoView.setOnErrorListener(this);
mVideoView.setOnSeekCompleteListener(mOnSeekCompleteListener);
mVideoView.setDisplayAspectRatio(PLVideoView.ASPECT_RATIO_PAVED_PARENT);
AVOptions options = new AVOptions();
// 解码方式:
// codec=AVOptions.MEDIA_CODEC_HW_DECODE,硬解
// codec=AVOptions.MEDIA_CODEC_SW_DECODE, 软解
// codec=AVOptions.MEDIA_CODEC_AUTO, 硬解优先,失败后自动切换到软解
// 默认值是:MEDIA_CODEC_SW_DECODE
options.setInteger(AVOptions.KEY_MEDIACODEC, AVOptions.MEDIA_CODEC_AUTO);
// 准备超时时间,包括创建资源、建立连接、请求码流等,单位是 ms
// 默认值是:无
options.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
// 读取视频流超时时间,单位是 ms
// 默认值是:10 * 1000
options.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
// 当前播放的是否为在线直播,如果是,则底层会有一些播放优化
// 默认值是:0为关闭 1为是
if (!replay) {
options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1);
// 是否开启"延时优化",只在在线直播流中有效
// 默认值是:0
options.setInteger(KEY_DELAY_OPTIMIZATION, 1);
} else {
XdyLogUtil.i(TAG, "回放设置AVOptions.KEY_LIVE_STREAMING, 0");
options.setInteger(AVOptions.KEY_LIVE_STREAMING, 0);
}
// 默认的缓存大小,单位是 ms
// 默认值是:2000
options.setInteger(AVOptions.KEY_CACHE_BUFFER_DURATION, 300);
// 最大的缓存大小,单位是 ms
// 默认值是:4000
options.setInteger(AVOptions.KEY_MAX_CACHE_BUFFER_DURATION, 300);
// 是否自动启动播放,如果设置为 1,则在调用 `prepareAsync` 或者 `setVideoPath` 之后自动启动播放,无需调用 `start()`
// 默认值是:1
options.setInteger(AVOptions.KEY_START_ON_PREPARED, 0);
// 播放前最大探测流的字节数,单位是 byte
// 默认值是:128 * 1024
options.setInteger(AVOptions.KEY_PROBESIZE, 128 * 1024);
options.setInteger(AVOptions.KEY_BUFFER_TIME, 300);
// 请在开始播放之前配置
mVideoView.setAVOptions(options);
}
@Override
public boolean onError(PLMediaPlayer plMediaPlayer, int i) {
return false;
}
@Override
public boolean onInfo(PLMediaPlayer plMediaPlayer, int i, int i1) {
// boolean videoMode = mPresenter.isVideoMode();
// if (videoMode && PLMediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START == i) {
//// initPic.setVisibility(View.INVISIBLE);
// }
return false;
}
private PLMediaPlayer.OnSeekCompleteListener mOnSeekCompleteListener = new PLMediaPlayer.OnSeekCompleteListener() {
@Override
public void onSeekComplete(PLMediaPlayer plMediaPlayer) {
Log.d(TAG, "onSeekComplete !");
}
};
private void setProgress() {
// if (!mDragging) {
// if (mEndTime != null)
// mEndTime.setText(generateTime(mPresenter.getRecordPlaybackMaxTime()));
// if (mCurrentTime != null)
// mCurrentTime.setText(generateTime(mPresenter.getCurrentTime()));
// if (mSeekBar != null)
// mSeekBar.setProgress(mPresenter.getCurrentTime());
// }
}
private String generateTime(long currentTime) {
int totalSeconds = (int) (currentTime);
int seconds = totalSeconds % 60;
int minutes = (totalSeconds / 60) % 60;
int hours = totalSeconds / 3600;
if (hours > 0) {
return String.format(Locale.US, "%02d:%02d:%02d", hours, minutes,
seconds).toString();
} else {
return String.format(Locale.US, "%02d:%02d", minutes, seconds)
.toString();
}
}
public void hideMediaContainer() {
if (!mDragging && mShowing) {
try {
mHandler.removeMessages(SHOW_PROGRESS);
mMediaContainer.setVisibility(View.GONE);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "MediaController already removed");
}
mShowing = false;
}
}
public void updatePausePlay() {
// if (mPresenter.getRecordStatus())
// mPauseButton.setImageResource(play);
// else
// mPauseButton.setImageResource(R.mipmap.stop);
// }
}
private void handleRecord(String pa) {
try {
JSONObject jsonObject = new JSONObject(pa);
int status = jsonObject.optInt("status");
switch (status) {
case Constants.RECORD_READY:
// pause = true;
// isOver = false;
break;
case Constants.RECORD_PLAYING:
// pause = false;
// isOver = false;
// mRootView.pauseOrStartEverything();
break;
case Constants.RECORD_SEEK:
// isOver = false;
// pause = false;
// int keyFrameSeek = jsonObject.optInt("keyFrameSeekTime");
// mRootView.seek(keyFrameSeek);
break;
case Constants.RECORD_STOP:
// pause = true;
// //停止后 录制回放要进行初始化
// if (!quit) {//回放结束了
// isOver = true;
// if (currentTime < recordPlaybackMaxTime)
// currentTime++;
// int classId = AccountUtils.getUser().getClassId();
// mModel.initRecordPlayback(classId, portal, userRole, userId);
// //停止视频
// mRootView.stopVideo();
// currentTime = 0;
// mRootView.resetSeekBar();
// docView.clear();
// chatView.clearChatHistory();
// currentPlayAudio = null;
// currentPlayVideo = null;
// }
break;
case Constants.RECORD_PAUSE:
// isOver = false;
// pause = true;
// mRootView.pauseOrStartEverything();
break;
}
// mRootView.updatePausePlay();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
... ...
... ... @@ -26,9 +26,13 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.mang.xdy.common.Constants;
import com.mang.xdy.core.SPUtil;
import com.mang.xdy.demo.R;
import com.mang.xdy.demo.bean.JoinClassSuccessEntity;
import com.mang.xdy.demo.bean.Message;
import com.mang.xdy.demo.fragment.ChatFragment;
import com.mang.xdy.demo.utils.JsonUtil;
import com.mang.xdy.demo.widget.chat.UrlUtils;
import com.mang.xdy.utils.XdyLogUtil;
... ... @@ -47,7 +51,7 @@ public class ChatAdapter extends BaseAdapter {
private KJBitmap kjb;
private ChatFragment.OnChatItemClickListener listener;
String oldTime;
String userRole="";
public ChatAdapter(Context cxt, List<Message> datas, ChatFragment.OnChatItemClickListener listener) {
this.cxt = cxt;
if (datas == null) {
... ... @@ -56,6 +60,7 @@ public class ChatAdapter extends BaseAdapter {
this.datas = datas;
kjb = new KJBitmap();
this.listener = listener;
getUserRole(cxt);
}
public void refresh(List<Message> datas) {
... ... @@ -158,53 +163,52 @@ public class ChatAdapter extends BaseAdapter {
kjb.display(holder.img_avatar, data.getToUserAvatar());
}*/
if (data.getIsSend()) {
XdyLogUtil.e("chatadapter getIsSend","hahhaahahhaahhhahaahahha");
// switch (AccountUtils.getUser().getUserRole()) {
// case "normal"://普通角色/学生
// if (!TextUtils.isEmpty(data.getFromUserName())) {
// holder.tv_name.setText(data.getFromUserName());
// } else {
// holder.tv_name.setText("学生");
// }
// holder.tv_teacher_bg.setVisibility(View.GONE);
// holder.img_avatar.setImageResource(R.mipmap.student);
// break;
// case "host"://主持人/老师
// if (TextUtils.isEmpty(data.getFromUserName())) {
// data.setFromUserName("老师");
// }
// holder.img_avatar.setImageResource(R.mipmap.teacher);
// holder.tv_name.setText(data.getFromUserName());
// holder.tv_teacher_bg.setVisibility(View.VISIBLE);
// break;
// case "presenter"://主讲人
// if (!TextUtils.isEmpty(data.getFromUserName())) {
// holder.tv_name.setText(data.getFromUserName());
// } else {
// holder.tv_name.setText("主讲人");
// }
// holder.tv_teacher_bg.setVisibility(View.GONE);
// holder.img_avatar.setImageResource(R.mipmap.student);
// break;
// case "assistant"://助教
// if (!TextUtils.isEmpty(data.getFromUserName())) {
// holder.tv_name.setText(data.getFromUserName());
// } else {
// holder.tv_name.setText("助教");
// }
// holder.tv_teacher_bg.setVisibility(View.GONE);
// holder.img_avatar.setImageResource(R.mipmap.student);
// break;
// case "record":// 暂时没用
// if (!TextUtils.isEmpty(data.getFromUserName())) {
// holder.tv_name.setText(data.getFromUserName());
// } else {
// holder.tv_name.setText("学生");
// }
// holder.tv_teacher_bg.setVisibility(View.GONE);
// holder.img_avatar.setImageResource(R.mipmap.student);
// break;
// }
switch (userRole) {
case "normal"://普通角色/学生
if (!TextUtils.isEmpty(data.getFromUserName())) {
holder.tv_name.setText(data.getFromUserName());
} else {
holder.tv_name.setText("学生");
}
holder.tv_teacher_bg.setVisibility(View.GONE);
holder.img_avatar.setImageResource(R.mipmap.student);
break;
case "host"://主持人/老师
if (TextUtils.isEmpty(data.getFromUserName())) {
data.setFromUserName("老师");
}
holder.img_avatar.setImageResource(R.mipmap.teacher);
holder.tv_name.setText(data.getFromUserName());
holder.tv_teacher_bg.setVisibility(View.VISIBLE);
break;
case "presenter"://主讲人
if (!TextUtils.isEmpty(data.getFromUserName())) {
holder.tv_name.setText(data.getFromUserName());
} else {
holder.tv_name.setText("主讲人");
}
holder.tv_teacher_bg.setVisibility(View.GONE);
holder.img_avatar.setImageResource(R.mipmap.student);
break;
case "assistant"://助教
if (!TextUtils.isEmpty(data.getFromUserName())) {
holder.tv_name.setText(data.getFromUserName());
} else {
holder.tv_name.setText("助教");
}
holder.tv_teacher_bg.setVisibility(View.GONE);
holder.img_avatar.setImageResource(R.mipmap.student);
break;
case "record":// 暂时没用
if (!TextUtils.isEmpty(data.getFromUserName())) {
holder.tv_name.setText(data.getFromUserName());
} else {
holder.tv_name.setText("学生");
}
holder.tv_teacher_bg.setVisibility(View.GONE);
holder.img_avatar.setImageResource(R.mipmap.student);
break;
}
}
else {
switch (data.getUserRole()) {
... ... @@ -311,4 +315,11 @@ public class ChatAdapter extends BaseAdapter {
final float scale = cxt.getResources().getDisplayMetrics().scaledDensity;
return spValue * scale;
}
public void getUserRole(Context context){
JoinClassSuccessEntity joinClassSuccessEntity= JsonUtil.parseJsonToBean(SPUtil.getString(context, Constants.CLASS_JOIN_SUCCESS,""),JoinClassSuccessEntity.class);
if(joinClassSuccessEntity!=null) {
userRole = joinClassSuccessEntity.getUserRole() ;
}
}
}
... ...
... ... @@ -21,13 +21,13 @@ public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter {
private String tabTitles[] = new String[]{"文档","聊天"};
private Context context;
private DocFragment docFragment=new DocFragment();
// private ChatFragment chatFragment=new ChatFragment();
private ChatFragment chatFragment=new ChatFragment();
private List<Fragment> fragmentList=new ArrayList<>();
public SimpleFragmentPagerAdapter(FragmentManager fm,Context context) {
super(fm);
this.context = context;
fragmentList.add(docFragment);
// fragmentList.add(chatFragment);
fragmentList.add(chatFragment);
}
@Override
... ...
... ... @@ -2,6 +2,7 @@ package com.mang.xdy.demo.fragment;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.Selection;
... ... @@ -88,6 +89,7 @@ public class ChatFragment extends Fragment implements ObserverListener{
// LogUtil.i("聊天内容===" + content);
// mPresenter.sendChatMsg(content, 0);
sendMeg(content);
box.hideKeyboard(mContext);
}
}
... ... @@ -253,12 +255,23 @@ public class ChatFragment extends Fragment implements ObserverListener{
};
}
private Handler mHandler=new Handler(){
@Override
public void handleMessage(android.os.Message msg) {
super.handleMessage(msg);
}
};
@Override
public void observerUpData(String type, String parameter) {
public void observerUpData(String type, final String parameter) {
switch (type) {
case Constants.CHAT_RECEIVE_MESSAGE:
mHandler.post(new Runnable() {
@Override
public void run() {
renderChatMsg(parameter);
}
});
break;
}
}
... ...
... ... @@ -8,20 +8,18 @@ import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.mang.xdy.common.Constants;
import com.mang.xdy.core.XdySdk;
import com.mang.xdy.demo.R;
import com.mang.xdy.demo.activity.VideoPlayActivity;
import com.mang.xdy.demo.base.BaseRunnable;
import com.mang.xdy.demo.bean.DocEntity;
import com.mang.xdy.demo.bean.GetDocImageEntity;
import com.mang.xdy.demo.bean.WhiteboardUpdateEntity;
import com.mang.xdy.demo.bean.WrapDocBitMapEntity;
import com.mang.xdy.demo.utils.JsonUtil;
... ... @@ -29,8 +27,8 @@ import com.mang.xdy.demo.utils.ToastUtil;
import com.mang.xdy.demo.widget.CanvasView;
import com.mang.xdy.listener.ObserverListener;
import com.mang.xdy.utils.XdyLogUtil;
import com.mang.xdy.utils.XdyStringUtils;
import com.squareup.picasso.Picasso;
import org.json.JSONObject;
import java.util.concurrent.ExecutionException;
... ... @@ -56,6 +54,8 @@ public class DocFragment extends Fragment implements ObserverListener{
int winWidth;
int winHeight;
private long intervalTime;
/*判断文档和白板是否匹配*/
private String mItemidx ="";
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
... ... @@ -105,6 +105,7 @@ public class DocFragment extends Fragment implements ObserverListener{
if (docEntity != null && docEntity.isVisible()==true&&docEntity.getImages()!= null&&docEntity.getImages().size()>=1) {
int currentPic=docEntity.getCurPageNo();
setDocImage(docEntity.getImages().get((currentPic>0) ? currentPic-1:0));
mItemidx = docEntity.getItemIdx()+"";
}
}
... ... @@ -150,6 +151,9 @@ public class DocFragment extends Fragment implements ObserverListener{
public void showDoc(String type,String response){
WhiteboardUpdateEntity whiteboardUpdateEntity= JsonUtil.parseJsonToBean(response,WhiteboardUpdateEntity.class);
if(whiteboardUpdateEntity!=null){
if(whiteboardUpdateEntity.annotaionItems!=null){
if (whiteboardUpdateEntity.annotaionItems.size()>0&& mItemidx.equals(whiteboardUpdateEntity.annotaionItems.get(0).parentId)){
if (intervalTime != 0) {
intervalTime = System.currentTimeMillis() - intervalTime;
if (intervalTime < 150) {//小于100毫秒 不执行?
... ... @@ -161,7 +165,8 @@ public class DocFragment extends Fragment implements ObserverListener{
}
intervalTime = System.currentTimeMillis();
}
}
}
}
private void delayDraw(final WhiteboardUpdateEntity entity) {
... ... @@ -244,7 +249,7 @@ public class DocFragment extends Fragment implements ObserverListener{
});
}
@Override
public void observerUpData(String type, String parameter) {
public void observerUpData(final String type, final String parameter) {
XdyLogUtil.e(TAG,"type:"+type+" response:"+parameter);
switch (type){
case Constants.DOCUMENT_UPDATE:
... ... @@ -254,7 +259,16 @@ public class DocFragment extends Fragment implements ObserverListener{
showDoc(type,parameter);
break;
case Constants.DOCUMENT_DELETE:
try {
JSONObject object = new JSONObject(parameter);
String itemIdx = object.optInt("itemIdx")+"";
if (!TextUtils.isEmpty(itemIdx)&& mItemidx.equals(itemIdx)){
docUrlTransformBitmap(null);
}
} catch (Exception e) {
e.printStackTrace();
}
break;
}
... ... @@ -263,6 +277,12 @@ public class DocFragment extends Fragment implements ObserverListener{
public void onDestroyView() {
super.onDestroyView();
xdySdk.remove(this);
if(mCanvasView!=null){
mCanvasView.clear();
}
if(bitmap!=null){
bitmap=null;
}
mHandler.removeCallbacksAndMessages(null);
}
}
... ...
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<size android:height="@dimen/ui_DIMEN_2.0PX"/>
<solid android:color="#f2f2f2"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<size android:height="@dimen/ui_DIMEN_2.0PX"/>
<solid android:color="#f2f2f2"/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<size android:height="@dimen/ui_DIMEN_2.0PX"/>
<solid android:color="#f55c22"/>
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/seek_btn"/>
<item android:state_pressed="false" android:drawable="@drawable/seek_btn"/>
</selector>
\ No newline at end of file
... ...
... ... @@ -6,6 +6,18 @@
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.mang.xdy.demo.activity.VideoPlayActivity">
<FrameLayout
android:id="@+id/fl_videoview_container"
android:layout_width="match_parent"
android:layout_height="10dp">
<com.pili.pldroid.player.widget.PLVideoTextureView
android:id="@+id/img_playVideo_replay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/ui_DIMEN_500.0PX">
... ... @@ -20,6 +32,12 @@
android:background="@mipmap/novideo"
/>
</RelativeLayout>
<Button
android:id="@+id/btn_videoPlay_exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="退出课堂,界面还在"
/>
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
... ... @@ -32,4 +50,16 @@
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white" />
<FrameLayout
android:id="@+id/fl_media"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="invisible">
<include
layout="@layout/home_media_controller"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
</LinearLayout>
... ...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/gradient_play"/>
<RelativeLayout
android:paddingLeft="@dimen/ui_DIMEN_20.0PX"
android:id="@+id/rl_operation_play"
android:layout_width="@dimen/ui_DIMEN_70.0PX"
android:layout_centerVertical="true"
android:layout_height="@dimen/ui_DIMEN_70.0PX">
<ImageButton
android:layout_marginLeft="@dimen/ui_DIMEN_20.0PX"
android:id="@+id/iv_operation_play"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:background="@null"
android:src="@mipmap/play"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_meadia_contriller_right"
android:gravity="center"
android:layout_toRightOf="@id/rl_operation_play"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/ui_DIMEN_6.0PX"
android:layout_height="@dimen/ui_DIMEN_70.0PX">
<TextView
android:id="@+id/tv_current_time"
style="@style/ui_wrapTvBaseStyle"
android:minWidth="@dimen/ui_DIMEN_100.0PX"
android:textColor="@color/white"
android:gravity="end"
tools:text="12:00:12"/>
<TextView
android:id="@+id/tv_end_time"
style="@style/ui_wrapTvBaseStyle"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/ui_DIMEN_30.0PX"
android:textColor="@color/white"
tools:text="12:00"/>
<SeekBar
android:id="@+id/sb_live"
style="@style/home_seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/tv_end_time"
android:layout_toRightOf="@id/tv_current_time"/>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
... ...
... ... @@ -105,4 +105,11 @@
<item name="android:textColor">@color/white</item>
<item name="android:textSize">@dimen/ui_DIMEN_34.0PX</item>
</style>
<style name="home_seek_bar" parent="@android:style/Widget.SeekBar">
<item name="android:maxHeight">1.5dip</item>
<item name="android:progressDrawable">@drawable/home_sb_progress</item>
<item name="android:minHeight">8.0dip</item>
<item name="android:thumb">@drawable/home_thunmb</item>
<item name="android:thumbOffset">10.0dip</item>
</style>
</resources>
... ...
... ... @@ -52,9 +52,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
/**
* @author Michael Yang(www.yangfuhai.com) update at 2013.08.07
*/
public class ACache {
public static final int TIME_HOUR = 60 * 60;
public static final int TIME_DAY = TIME_HOUR * 24;
... ...
... ... @@ -176,7 +176,14 @@ public interface Constants {
String ERROR_XDYCORE_INIT="Uninitialized initialization, please init xysdk";
/*判断输入的类型是否为空*/
String ERROR_TYPE_NULL="输入的type不能为空";
/**
* surfaceview 为null
*/
String ERROR_TYPE_SURFACEVIEW="xdysdk surfaceview is null";
/**
* activity is null
*/
String ERROR_TYPE_ACTIVITY="xdysdk activity is null";
/**********************************以下实现为自定义code 先定义后实现*********************************************************************/
/**
... ...
... ... @@ -24,6 +24,8 @@ public class XdyJsCore {
private WebView mWebView;
private static String TAG="xdyjscore";
private static XdyJsCore mXdyCore;
protected boolean isDestroy=false;
private XdyJavaScript mXdyJavaScript;
/**
* 异步对外回调接口,所有回调都在此完成
*/
... ... @@ -50,16 +52,21 @@ public class XdyJsCore {
* @param context
*/
protected void init(Context context){
//清理Webview缓存数据库
mWebView=new WebView(context);
WebSettings webSettings=mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new XdyJavaScript(), APIContants.NATIVE_JS_LINK);
mWebView.getSettings().setAppCacheEnabled(false);
webSettings. setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
mXdyJavaScript=new XdyJavaScript();
mWebView.addJavascriptInterface(mXdyJavaScript, APIContants.NATIVE_JS_LINK);
mWebView.setWebChromeClient(new WebChromeClient(){
@Override
public void onConsoleMessage(String message, int lineNumber, String sourceID) {
super.onConsoleMessage(message, lineNumber, sourceID);
//TODO 发布时去掉
// XdyLogUtil.e("message:"+message+" lineNumber:"+" sourceId:"+sourceID);
XdyLogUtil.e("message:"+message+" lineNumber:"+" sourceId:"+sourceID);
}
});
mWebView.post(new Runnable() {
... ... @@ -96,8 +103,7 @@ public class XdyJsCore {
if(mOnXdyAsyncMessageListener !=null){
mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,parmp);
}
//TODo 使用观察者传递数
XdySdk.getXdyInstance().notifyObserver(id,parmp);
XdySdk.getXdyInstance().notifyObserver(id, parmp);
}
}
... ... @@ -106,11 +112,9 @@ public class XdyJsCore {
* @param id
* @param parameter
*/
protected void native2js(final String id, final String parameter) {
protected void native2js( String id, String parameter) {
XdyLogUtil.e("推流线程native2js:",Thread.currentThread().getId()+"");
// mWebView.post(new Runnable() {
// @Override
// public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mWebView.evaluateJavascript("javascript:_native2js('" + id + "','"+parameter+"')", new ValueCallback<String>() {
@Override
... ... @@ -122,11 +126,11 @@ public class XdyJsCore {
// mOnXdyAsyncMessageListener.getSdyAsyncMessageListener("live",value);
// }
// }
if (!TextUtils.isEmpty(value)&&value.length()>10) {
if(mOnXdyAsyncMessageListener !=null){
mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,value);
}
}
// if (!TextUtils.isEmpty(value)&&value.length()>10) {
// if(mOnXdyAsyncMessageListener !=null){
// mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,value);
// }
// }
}
});
}else{
... ... @@ -134,6 +138,17 @@ public class XdyJsCore {
}
}
// });
// }
/**
* 清除缓存
*/
public void onDestroy(){
if(mWebView!=null){
mWebView.clearHistory();
}
if(mXdyJavaScript!=null){
mXdyJavaScript=null;
}
mXdyJavaScript= new XdyJavaScript();
}
}
... ...
... ... @@ -48,7 +48,7 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC
private int videoHight = 480;
private boolean isStart = false;
/*是否支持硬编码 默认不支持*/
private boolean is_hardware_encoder = true;
private boolean is_hardware_encoder = false;
static {
System.loadLibrary("SmartPublisher");
... ...
... ... @@ -59,6 +59,7 @@ public class XdySdk implements SubjectListener{
private Activity mActivity;
/*是否正在推流,mcu自动断开的时候使用,推流成功后才表示正在使用*/
private boolean isPublisher=false;
/*观察者集合*/
private List<ObserverListener> observerListenerList=new ArrayList<ObserverListener>();
@Override
... ... @@ -71,8 +72,6 @@ public class XdySdk implements SubjectListener{
handleData(type,parameter);
XdyLogUtil.e("notifyObserVer","type:"+type+" parameter:"+parameter);
}
@Override
... ... @@ -83,6 +82,16 @@ public class XdySdk implements SubjectListener{
}
/**
* 清除信息
*/
public void removeAll(){
// if(observerListenerList!=null){
// observerListenerList.clear();
// }
mXdyJsCore.onDestroy();
}
/**
* 对外提供的异步消息接收接口)
*/
public interface OnXdyAsyncMessageLitener{
... ... @@ -99,7 +108,7 @@ public class XdySdk implements SubjectListener{
* 设置监听
*/
public void setOnXdyAsyncMessageLitener(OnXdyAsyncMessageLitener onXdyAsyncMessageLitener){
judgeCore();;
judgeCore();
mOnXdyAsyncMessageLitener=onXdyAsyncMessageLitener;
}
private XdySdk(){}
... ... @@ -142,6 +151,7 @@ public class XdySdk implements SubjectListener{
// @Override
// public void run() {
// handleData(id,parameter);
//
// }
// });
//
... ... @@ -171,6 +181,9 @@ public class XdySdk implements SubjectListener{
//停止播放video( 停止播放:根据api)
// onPlayStop();
break;
case "init":
mXdyJsCore.isDestroy=false;
break;
}
handler.post(new Runnable() {
@Override
... ... @@ -256,7 +269,7 @@ public class XdySdk implements SubjectListener{
case Constants.PUBLISH_AUDIO:
//只推送音频
getPublishPathAudio();
mSurfaceView=surfaceView;
// mSurfaceView=surfaceView;
mActivity=activity;
break;
... ... @@ -322,17 +335,17 @@ public class XdySdk implements SubjectListener{
if(getPublishPathReceiveBean!=null) {
//可以推流了
if (getPublishPathReceiveBean.getCode() == 0) {
//TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字
//TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用video_get_publish_path关键字 只支持做只支一路
String video_url = getPublishPathReceiveBean.getPublishUrl();
aCache.put(Constants.VIDEO_GET_PUBLISH_PATH, video_url);
//判断
if (mSurfaceView == null) {
//todo 输出提示
return;
throw new IllegalArgumentException(Constants.ERROR_TYPE_SURFACEVIEW);
}
if (mActivity == null) {
//TODo 给出提示
return;
throw new IllegalArgumentException(Constants.ERROR_TYPE_ACTIVITY);
}
if (mXdyPublisherCore == null) {
mXdyPublisherCore = new XdyPublisherCore(1, 1, mActivity);
... ... @@ -360,11 +373,11 @@ public class XdySdk implements SubjectListener{
//TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字
aCache.put(Constants.GET_VIDEO_PUBLISH_PATH,audio_url);
//判断
if (mSurfaceView==null){
//todo 输出提示
XdyLogUtil.e(TAG,"surfaceView is null");
return;
}
// if (mSurfaceView==null){
// //todo 输出提示
// XdyLogUtil.e(TAG,"surfaceView is null");
// return;
// }
if(mActivity==null){
//TODo 给出提示
XdyLogUtil.e(TAG,"activity is null");
... ... @@ -540,11 +553,12 @@ public class XdySdk implements SubjectListener{
break;
case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP:
Log.i(TAG, "关闭。。");
XdySdk.getXdyInstance().notifyObserver("play_stop",currentPlayId+"");
notifyObserver("play_stop",currentPlayId+"");
break;
case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO:
Log.i(TAG, "分辨率信息: width: " + param1 + ", height: " + param2);
XdySdk.getXdyInstance().notifyObserver("video_success",currentPlayId+"");
//在这里最接近得到播放的成功的准确回调
notifyObserver("video_success",currentPlayId+"");
break;
case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED:
Log.i(TAG, "收不到媒体数据,可能是url错误。。");
... ...
... ... @@ -6,7 +6,7 @@ package com.mang.xdy.listener;
public interface ObserverListener {
/**
*
*更新数据
* @param type 类型
* @param parameter 参数
*/
... ...
... ... @@ -5,7 +5,21 @@ package com.mang.xdy.listener;
*/
public interface SubjectListener {
/**
* 添加监听
* @param observerListener
*/
void add(ObserverListener observerListener);
/**
* 更新数据
* @param type
* @param parameter
*/
void notifyObserver(String type,String parameter);
/**
* 移除监听
* @param observerListener
*/
void remove(ObserverListener observerListener);
}
... ...