正在显示
20 个修改的文件
包含
747 行增加
和
218 行删除
| @@ -49,4 +49,7 @@ dependencies { | @@ -49,4 +49,7 @@ dependencies { | ||
| 49 | 49 | ||
| 50 | compile 'com.nineoldandroids:library:2.4.0' | 50 | compile 'com.nineoldandroids:library:2.4.0' |
| 51 | compile 'me.yokeyword:fragmentation:0.10.3' | 51 | compile 'me.yokeyword:fragmentation:0.10.3' |
| 52 | + | ||
| 53 | + compile files('libs/pldroid-player-1.5.1.jar') | ||
| 54 | + compile 'com.qiniu:happy-dns:0.2.+' | ||
| 52 | } | 55 | } |
不能预览此文件类型
| @@ -3,6 +3,7 @@ package com.mang.xdy.demo; | @@ -3,6 +3,7 @@ package com.mang.xdy.demo; | ||
| 3 | import android.content.Intent; | 3 | import android.content.Intent; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | import android.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
| 6 | +import android.text.TextUtils; | ||
| 6 | import android.view.View; | 7 | import android.view.View; |
| 7 | import android.widget.Button; | 8 | import android.widget.Button; |
| 8 | import android.widget.EditText; | 9 | import android.widget.EditText; |
| @@ -12,6 +13,7 @@ import com.mang.xdy.demo.activity.AudioPublisherActivity; | @@ -12,6 +13,7 @@ import com.mang.xdy.demo.activity.AudioPublisherActivity; | ||
| 12 | import com.mang.xdy.demo.activity.VideoPlayActivity; | 13 | import com.mang.xdy.demo.activity.VideoPlayActivity; |
| 13 | import com.mang.xdy.demo.activity.VideoPublisherActivity; | 14 | import com.mang.xdy.demo.activity.VideoPublisherActivity; |
| 14 | import com.mang.xdy.demo.bean.JoinClassBean; | 15 | import com.mang.xdy.demo.bean.JoinClassBean; |
| 16 | +import com.mang.xdy.demo.utils.ToastUtil; | ||
| 15 | import com.mang.xdy.utils.XdyLogUtil; | 17 | import com.mang.xdy.utils.XdyLogUtil; |
| 16 | 18 | ||
| 17 | import butterknife.BindView; | 19 | import butterknife.BindView; |
| @@ -44,6 +46,9 @@ public class MainActivity extends AppCompatActivity { | @@ -44,6 +46,9 @@ public class MainActivity extends AppCompatActivity { | ||
| 44 | 46 | ||
| 45 | @OnClick({R.id.btn_home_enter_class,R.id.btn_home_enter_publisher,R.id.btn_home_enter_publisherAudio}) | 47 | @OnClick({R.id.btn_home_enter_class,R.id.btn_home_enter_publisher,R.id.btn_home_enter_publisherAudio}) |
| 46 | public void onViewClicked(View view) { | 48 | public void onViewClicked(View view) { |
| 49 | + if(TextUtils.isEmpty(joinClass())){ | ||
| 50 | + return; | ||
| 51 | + } | ||
| 47 | switch (view.getId()){ | 52 | switch (view.getId()){ |
| 48 | 53 | ||
| 49 | case R.id.btn_home_enter_class: | 54 | case R.id.btn_home_enter_class: |
| @@ -63,17 +68,47 @@ public class MainActivity extends AppCompatActivity { | @@ -63,17 +68,47 @@ public class MainActivity extends AppCompatActivity { | ||
| 63 | break; | 68 | break; |
| 64 | } | 69 | } |
| 65 | } | 70 | } |
| 66 | - | 71 | + private String classId=""; |
| 72 | + private String userRole=""; | ||
| 73 | + private String serviceIp=""; | ||
| 74 | + private String userId=""; | ||
| 75 | + public boolean getLoginInfo(){ | ||
| 76 | + classId=edtHomeClassId.getText().toString(); | ||
| 77 | + userRole=edtHomeRole.getText().toString(); | ||
| 78 | + serviceIp=edtHomeServiceIp.getText().toString(); | ||
| 79 | + userId=edtHomeUserId.getText().toString(); | ||
| 80 | + if(TextUtils.isEmpty(classId)){ | ||
| 81 | + ToastUtil.showToast("课堂Id不能为空",this); | ||
| 82 | + return false; | ||
| 83 | + } | ||
| 84 | + if(TextUtils.isEmpty(serviceIp)){ | ||
| 85 | + ToastUtil.showToast("服务器地址不能为空",this); | ||
| 86 | + return false; | ||
| 87 | + } | ||
| 88 | + if(TextUtils.isEmpty(userRole)){ | ||
| 89 | + ToastUtil.showToast("角色不能为空",this); | ||
| 90 | + return false; | ||
| 91 | + } | ||
| 92 | + if(TextUtils.isEmpty(userId)){ | ||
| 93 | + ToastUtil.showToast("用户id不能为空",this); | ||
| 94 | + return false; | ||
| 95 | + } | ||
| 96 | + return true; | ||
| 97 | + } | ||
| 67 | public String joinClass(){ | 98 | public String joinClass(){ |
| 68 | - JoinClassBean joinClassBean=new JoinClassBean(); | ||
| 69 | - joinClassBean.setClassId(Integer.parseInt(edtHomeClassId.getText().toString())); | ||
| 70 | - joinClassBean.setUserRole(edtHomeRole.getText().toString()); | ||
| 71 | - joinClassBean.setPortal(edtHomeServiceIp.getText().toString()); | ||
| 72 | - joinClassBean.setUserId(Integer.parseInt(edtHomeUserId.getText().toString())); | ||
| 73 | - joinClassBean.setUserName(""); | ||
| 74 | - String joinclass=new Gson().toJson(joinClassBean); | ||
| 75 | - XdyLogUtil.e("init 初始化",joinclass); | ||
| 76 | - return joinclass; | 99 | + if(getLoginInfo()) { |
| 100 | + JoinClassBean joinClassBean = new JoinClassBean(); | ||
| 101 | + joinClassBean.setClassId(Integer.parseInt(classId)); | ||
| 102 | + joinClassBean.setUserRole(userRole); | ||
| 103 | + joinClassBean.setPortal(serviceIp); | ||
| 104 | + joinClassBean.setUserId(Integer.parseInt(userId)); | ||
| 105 | + joinClassBean.setUserName(""); | ||
| 106 | + String joinclass = new Gson().toJson(joinClassBean); | ||
| 107 | +// XdyLogUtil.e("init 初始化", joinclass); | ||
| 108 | + return joinclass; | ||
| 109 | + }else{ | ||
| 110 | + return ""; | ||
| 111 | + } | ||
| 77 | 112 | ||
| 78 | } | 113 | } |
| 79 | } | 114 | } |
| 1 | package com.mang.xdy.demo.activity; | 1 | package com.mang.xdy.demo.activity; |
| 2 | ; | 2 | ; |
| 3 | -import android.app.Dialog; | 3 | +import android.annotation.SuppressLint; |
| 4 | import android.app.ProgressDialog; | 4 | import android.app.ProgressDialog; |
| 5 | -import android.content.Context; | ||
| 6 | import android.content.DialogInterface; | 5 | import android.content.DialogInterface; |
| 7 | import android.os.Bundle; | 6 | import android.os.Bundle; |
| 8 | import android.os.Handler; | 7 | import android.os.Handler; |
| @@ -11,30 +10,29 @@ import android.support.design.widget.TabLayout; | @@ -11,30 +10,29 @@ import android.support.design.widget.TabLayout; | ||
| 11 | import android.support.v4.view.ViewPager; | 10 | import android.support.v4.view.ViewPager; |
| 12 | import android.support.v7.app.AlertDialog; | 11 | import android.support.v7.app.AlertDialog; |
| 13 | import android.support.v7.app.AppCompatActivity; | 12 | import android.support.v7.app.AppCompatActivity; |
| 14 | -import android.text.TextUtils; | ||
| 15 | -import android.view.Gravity; | 13 | +import android.util.Log; |
| 16 | import android.view.SurfaceView; | 14 | import android.view.SurfaceView; |
| 17 | import android.view.View; | 15 | import android.view.View; |
| 18 | -import android.view.Window; | ||
| 19 | import android.view.WindowManager; | 16 | import android.view.WindowManager; |
| 20 | import android.widget.Button; | 17 | import android.widget.Button; |
| 21 | -import android.widget.EditText; | 18 | +import android.widget.FrameLayout; |
| 19 | +import android.widget.ImageButton; | ||
| 22 | import android.widget.ImageView; | 20 | import android.widget.ImageView; |
| 21 | +import android.widget.RelativeLayout; | ||
| 22 | +import android.widget.SeekBar; | ||
| 23 | +import android.widget.TextView; | ||
| 24 | + | ||
| 23 | import com.google.gson.Gson; | 25 | import com.google.gson.Gson; |
| 24 | -import com.google.gson.JsonNull; | ||
| 25 | import com.mang.xdy.common.Constants; | 26 | import com.mang.xdy.common.Constants; |
| 26 | import com.mang.xdy.core.SPUtil; | 27 | import com.mang.xdy.core.SPUtil; |
| 27 | import com.mang.xdy.core.XdySdk; | 28 | import com.mang.xdy.core.XdySdk; |
| 28 | import com.mang.xdy.demo.R; | 29 | import com.mang.xdy.demo.R; |
| 29 | import com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter; | 30 | import com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter; |
| 30 | -import com.mang.xdy.demo.bean.DocEntity; | ||
| 31 | import com.mang.xdy.demo.bean.ErrorEntity; | 31 | import com.mang.xdy.demo.bean.ErrorEntity; |
| 32 | -import com.mang.xdy.demo.bean.GetDocImageEntity; | ||
| 33 | import com.mang.xdy.demo.bean.InitClassSuccessEntity; | 32 | import com.mang.xdy.demo.bean.InitClassSuccessEntity; |
| 34 | import com.mang.xdy.demo.bean.JoinClass; | 33 | import com.mang.xdy.demo.bean.JoinClass; |
| 35 | import com.mang.xdy.demo.bean.ResponseEntity; | 34 | import com.mang.xdy.demo.bean.ResponseEntity; |
| 36 | import com.mang.xdy.demo.bean.VideoOrAudioStopEntity; | 35 | import com.mang.xdy.demo.bean.VideoOrAudioStopEntity; |
| 37 | -import com.mang.xdy.demo.bean.VideoPlayBean; | ||
| 38 | import com.mang.xdy.demo.utils.JsonUtil; | 36 | import com.mang.xdy.demo.utils.JsonUtil; |
| 39 | import com.mang.xdy.demo.utils.ToastUtil; | 37 | import com.mang.xdy.demo.utils.ToastUtil; |
| 40 | import com.mang.xdy.demo.widget.dialog.LoginDialog; | 38 | import com.mang.xdy.demo.widget.dialog.LoginDialog; |
| @@ -42,19 +40,30 @@ import com.mang.xdy.listener.ObserverListener; | @@ -42,19 +40,30 @@ import com.mang.xdy.listener.ObserverListener; | ||
| 42 | import com.mang.xdy.utils.UIUtils; | 40 | import com.mang.xdy.utils.UIUtils; |
| 43 | import com.mang.xdy.utils.XdyLogUtil; | 41 | import com.mang.xdy.utils.XdyLogUtil; |
| 44 | import com.mang.xdy.utils.XdyStringUtils; | 42 | import com.mang.xdy.utils.XdyStringUtils; |
| 43 | +import com.pili.pldroid.player.AVOptions; | ||
| 44 | +import com.pili.pldroid.player.PLMediaPlayer; | ||
| 45 | +import com.pili.pldroid.player.widget.PLVideoTextureView; | ||
| 46 | +import com.pili.pldroid.player.widget.PLVideoView; | ||
| 47 | + | ||
| 45 | 48 | ||
| 49 | +import org.json.JSONException; | ||
| 50 | +import org.json.JSONObject; | ||
| 51 | + | ||
| 52 | +import java.util.Locale; | ||
| 46 | 53 | ||
| 47 | import butterknife.BindView; | 54 | import butterknife.BindView; |
| 48 | import butterknife.ButterKnife; | 55 | import butterknife.ButterKnife; |
| 49 | 56 | ||
| 50 | -import static com.mang.xdy.demo.application.XdyApplicaiton.getActivity; | 57 | +import static com.pili.pldroid.player.AVOptions.KEY_DELAY_OPTIMIZATION; |
| 51 | 58 | ||
| 52 | -public class VideoPlayActivity extends AppCompatActivity implements ObserverListener{ | 59 | +public class VideoPlayActivity extends AppCompatActivity implements ObserverListener, PLMediaPlayer.OnErrorListener, PLMediaPlayer.OnInfoListener { |
| 53 | private final static String TAG = "VideoPlayActivity"; | 60 | private final static String TAG = "VideoPlayActivity"; |
| 54 | @BindView(R.id.img_playVideo_novideo) | 61 | @BindView(R.id.img_playVideo_novideo) |
| 55 | ImageView img_playVideo_novideo; | 62 | ImageView img_playVideo_novideo; |
| 56 | - private String username=""; | ||
| 57 | - private String userpwd=""; | 63 | + @BindView(R.id.btn_videoPlay_exit) |
| 64 | + Button btn_videoPlay_exit; | ||
| 65 | + private String username = ""; | ||
| 66 | + private String userpwd = ""; | ||
| 58 | private SimpleFragmentPagerAdapter pagerAdapter; | 67 | private SimpleFragmentPagerAdapter pagerAdapter; |
| 59 | private ViewPager viewPager; | 68 | private ViewPager viewPager; |
| 60 | private TabLayout tabLayout; | 69 | private TabLayout tabLayout; |
| @@ -64,66 +73,102 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -64,66 +73,102 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 64 | private XdySdk xdySdk; | 73 | private XdySdk xdySdk; |
| 65 | private LoginDialog mLoginDialog; | 74 | private LoginDialog mLoginDialog; |
| 66 | private ProgressDialog mProgressDialog; | 75 | private ProgressDialog mProgressDialog; |
| 67 | - private Handler mHandler=new Handler(){ | ||
| 68 | - @Override | ||
| 69 | - public void handleMessage(Message msg) { | ||
| 70 | - super.handleMessage(msg); | ||
| 71 | - ResponseEntity responseEntity= (ResponseEntity) msg.obj; | ||
| 72 | - switch (responseEntity.getType()){ | ||
| 73 | - case Constants.ERROR_CODE: | ||
| 74 | - handError(responseEntity.getType(),responseEntity.getParam()); | ||
| 75 | - break; | ||
| 76 | - case Constants.CLASS_INIT_SUCCESS: | ||
| 77 | - String login=responseEntity.getParam(); | ||
| 78 | - parseJoinClass(login,true); | ||
| 79 | - ToastUtil.showToastshort("初始化课堂成功", VideoPlayActivity.this); | ||
| 80 | - break; | ||
| 81 | - case Constants.CLASS_JOIN_SUCCESS: | ||
| 82 | - //加入课堂成功 | ||
| 83 | - progressDialogDismiss(); | ||
| 84 | - UIUtils.closeDialog(mLoginDialog); | ||
| 85 | - ToastUtil.showToastshort("加入课堂成功", VideoPlayActivity.this); | ||
| 86 | - String userJson=responseEntity.getParam(); | ||
| 87 | - SPUtil.putString(VideoPlayActivity.this, Constants.CLASS_JOIN_SUCCESS,userJson); | ||
| 88 | - break; | ||
| 89 | - case Constants.VIDEO_PLAY: | ||
| 90 | - //播放视频 | ||
| 91 | - playVideo(responseEntity.getParam()); | ||
| 92 | - break; | ||
| 93 | - case Constants.AUDIO_PLAY: | ||
| 94 | - //播放音频 | ||
| 95 | - playAudio(responseEntity.getParam()); | ||
| 96 | - break; | ||
| 97 | - case Constants.VIDEO_STOP: | ||
| 98 | - //停止播放 | ||
| 99 | - case Constants.AUDIO_STOP: | ||
| 100 | - //停止播放 | ||
| 101 | - stopPlay(responseEntity.getParam()); | ||
| 102 | - break; | ||
| 103 | - case "video_success": | ||
| 104 | - img_playVideo_novideo.setVisibility(View.GONE); | ||
| 105 | - break; | ||
| 106 | - | ||
| 107 | - } | ||
| 108 | - } | ||
| 109 | - }; | 76 | + @BindView(R.id.img_playVideo_replay) |
| 77 | + PLVideoTextureView mVideoView; | ||
| 78 | + //TODO 默认回放 | ||
| 79 | + private boolean replay = true; | ||
| 80 | + private Handler mmHandler = new Handler() { | ||
| 81 | + @Override | ||
| 82 | + public void handleMessage(Message msg) { | ||
| 83 | + super.handleMessage(msg); | ||
| 84 | + ResponseEntity responseEntity = (ResponseEntity) msg.obj; | ||
| 85 | + switch (responseEntity.getType()) { | ||
| 86 | + case Constants.ERROR_CODE: | ||
| 87 | + handError(responseEntity.getType(), responseEntity.getParam()); | ||
| 88 | + break; | ||
| 89 | + case Constants.CLASS_INIT_SUCCESS: | ||
| 90 | + String login = responseEntity.getParam(); | ||
| 91 | + parseJoinClass(login, true); | ||
| 92 | + ToastUtil.showToastshort("初始化课堂成功", VideoPlayActivity.this); | ||
| 93 | + break; | ||
| 94 | + case Constants.CLASS_JOIN_SUCCESS: | ||
| 95 | + //加入课堂成功 | ||
| 96 | + progressDialogDismiss(); | ||
| 97 | + UIUtils.closeDialog(mLoginDialog); | ||
| 98 | + ToastUtil.showToastshort("加入课堂成功", VideoPlayActivity.this); | ||
| 99 | + String userJson = responseEntity.getParam(); | ||
| 100 | + SPUtil.putString(VideoPlayActivity.this, Constants.CLASS_JOIN_SUCCESS, userJson); | ||
| 101 | + break; | ||
| 102 | + case Constants.VIDEO_PLAY: | ||
| 103 | + //播放视频 | ||
| 104 | + playVideo(responseEntity.getParam()); | ||
| 105 | + break; | ||
| 106 | + case Constants.AUDIO_PLAY: | ||
| 107 | + //播放音频 | ||
| 108 | + playAudio(responseEntity.getParam()); | ||
| 109 | + break; | ||
| 110 | + case Constants.VIDEO_STOP: | ||
| 111 | + //停止播放 | ||
| 112 | + case Constants.AUDIO_STOP: | ||
| 113 | + //停止播放 | ||
| 114 | + stopPlay(responseEntity.getParam()); | ||
| 115 | + break; | ||
| 116 | + case "video_success": | ||
| 117 | + //自定义消息 播放视频音频都通过这个来判断 | ||
| 118 | + img_playVideo_novideo.setVisibility(View.GONE); | ||
| 119 | + break; | ||
| 120 | + | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + }; | ||
| 124 | + | ||
| 110 | @Override | 125 | @Override |
| 111 | protected void onCreate(final Bundle savedInstanceState) { | 126 | protected void onCreate(final Bundle savedInstanceState) { |
| 112 | super.onCreate(savedInstanceState); | 127 | super.onCreate(savedInstanceState); |
| 113 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //屏幕常亮 | 128 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //屏幕常亮 |
| 114 | setContentView(R.layout.activity_video_play); | 129 | setContentView(R.layout.activity_video_play); |
| 115 | ButterKnife.bind(this); | 130 | ButterKnife.bind(this); |
| 116 | - xdySdk=XdySdk.getXdyInstance(); | 131 | + XdySdk.init(this); |
| 132 | + xdySdk = XdySdk.getXdyInstance(); | ||
| 117 | xdySdk.add(this); | 133 | xdySdk.add(this); |
| 118 | init(); | 134 | init(); |
| 119 | progressDialogShow(); | 135 | progressDialogShow(); |
| 120 | - setTablayout(); | 136 | + setTablayout(); |
| 121 | } | 137 | } |
| 122 | 138 | ||
| 123 | public void init() { | 139 | public void init() { |
| 124 | initClass = getIntent().getStringExtra("init"); | 140 | initClass = getIntent().getStringExtra("init"); |
| 125 | xdySdk.api("init", initClass); | 141 | xdySdk.api("init", initClass); |
| 142 | + btn_videoPlay_exit.setOnClickListener(new View.OnClickListener() { | ||
| 143 | + @Override | ||
| 144 | + public void onClick(View v) { | ||
| 145 | +// xdySdk.api("leaveClass", ""); | ||
| 146 | + | ||
| 147 | +// | ||
| 148 | +// xdySdk.remove(VideoPlayActivity.this); | ||
| 149 | +// xdySdk.removeAll(); | ||
| 150 | +// UIUtils.closeDialog(mLoginDialog); | ||
| 151 | +// VideoPlayActivity.super.onBackPressed(); | ||
| 152 | +// Exit(); | ||
| 153 | + String id="initRecordPlayback"; | ||
| 154 | + String param="{\n" + | ||
| 155 | + " \"classId\": 479270427 ,\n" + | ||
| 156 | + " \"portal\": \"112.126.80.182:90\",\n" + | ||
| 157 | + " \"userRole\": \"normal\",\n" + | ||
| 158 | + " \"userName\": \"\",\n" + | ||
| 159 | + " \"userId\": 0\n" + | ||
| 160 | + "}"; | ||
| 161 | + String ss=XdyStringUtils.stringToJson(param,true); | ||
| 162 | + xdySdk.api(id,ss); | ||
| 163 | + mHandler.postDelayed(new Runnable() { | ||
| 164 | + @Override | ||
| 165 | + public void run() { | ||
| 166 | + xdySdk.api("startRecordPlayback", ""); | ||
| 167 | + } | ||
| 168 | + }, 200); | ||
| 126 | 169 | ||
| 170 | + } | ||
| 171 | + }); | ||
| 127 | } | 172 | } |
| 128 | 173 | ||
| 129 | public void setTablayout() { | 174 | public void setTablayout() { |
| @@ -134,17 +179,18 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -134,17 +179,18 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 134 | tabLayout.setupWithViewPager(viewPager); | 179 | tabLayout.setupWithViewPager(viewPager); |
| 135 | tabLayout.setTabMode(TabLayout.MODE_FIXED); | 180 | tabLayout.setTabMode(TabLayout.MODE_FIXED); |
| 136 | } | 181 | } |
| 182 | + | ||
| 137 | //判断解析是否有密码 | 183 | //判断解析是否有密码 |
| 138 | - public void parseJoinClass(String rsponse,boolean isShowPwd){ | ||
| 139 | - InitClassSuccessEntity initClassSuccessEntity=JsonUtil.parseJsonToBean(rsponse,InitClassSuccessEntity.class); | ||
| 140 | - if(initClassSuccessEntity!=null) { | 184 | + public void parseJoinClass(String rsponse, boolean isShowPwd) { |
| 185 | + InitClassSuccessEntity initClassSuccessEntity = JsonUtil.parseJsonToBean(rsponse, InitClassSuccessEntity.class); | ||
| 186 | + if (initClassSuccessEntity != null) { | ||
| 141 | if (initClassSuccessEntity.isPasswordRequired()) { | 187 | if (initClassSuccessEntity.isPasswordRequired()) { |
| 142 | - isShowPwd=true; | ||
| 143 | - } else { | ||
| 144 | - isShowPwd=false; | ||
| 145 | - userpwd = "123321"; | 188 | + isShowPwd = true; |
| 189 | + } else { | ||
| 190 | + isShowPwd = false; | ||
| 191 | + userpwd = "123321"; | ||
| 192 | + } | ||
| 146 | } | 193 | } |
| 147 | - } | ||
| 148 | if (mLoginDialog == null) { | 194 | if (mLoginDialog == null) { |
| 149 | mLoginDialog = new LoginDialog(this, isShowPwd, null); | 195 | mLoginDialog = new LoginDialog(this, isShowPwd, null); |
| 150 | mLoginDialog.show(); | 196 | mLoginDialog.show(); |
| @@ -159,40 +205,40 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -159,40 +205,40 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 159 | progressDialogShow(); | 205 | progressDialogShow(); |
| 160 | } | 206 | } |
| 161 | }); | 207 | }); |
| 162 | - }else if (mLoginDialog != null) { | 208 | + } else if (mLoginDialog != null) { |
| 163 | UIUtils.closeDialog(mLoginDialog); | 209 | UIUtils.closeDialog(mLoginDialog); |
| 164 | } | 210 | } |
| 165 | } | 211 | } |
| 166 | 212 | ||
| 167 | //加入课堂 | 213 | //加入课堂 |
| 168 | - public void joinClass(String rsponse,boolean isShowPwd) { | ||
| 169 | - JoinClass joinClass=new JoinClass(); | 214 | + public void joinClass(String rsponse, boolean isShowPwd) { |
| 215 | + JoinClass joinClass = new JoinClass(); | ||
| 170 | joinClass.setHasCamera(false); | 216 | joinClass.setHasCamera(false); |
| 171 | joinClass.setHasMicrophone(false); | 217 | joinClass.setHasMicrophone(false); |
| 172 | joinClass.setUserName(username); | 218 | joinClass.setUserName(username); |
| 173 | - if(!isShowPwd){ | 219 | + if (!isShowPwd) { |
| 174 | joinClass.setPassword("123321"); | 220 | joinClass.setPassword("123321"); |
| 175 | - }else{ | 221 | + } else { |
| 176 | joinClass.setPassword(userpwd); | 222 | joinClass.setPassword(userpwd); |
| 177 | } | 223 | } |
| 178 | - String temp=new Gson().toJson(joinClass); | 224 | + String temp = new Gson().toJson(joinClass); |
| 179 | String jsonParmp = XdyStringUtils.stringToJson(temp, true); | 225 | String jsonParmp = XdyStringUtils.stringToJson(temp, true); |
| 180 | XdyLogUtil.e("加入课堂", jsonParmp); | 226 | XdyLogUtil.e("加入课堂", jsonParmp); |
| 181 | xdySdk.api("joinClass", jsonParmp); | 227 | xdySdk.api("joinClass", jsonParmp); |
| 182 | } | 228 | } |
| 183 | 229 | ||
| 184 | //加入课堂 | 230 | //加入课堂 |
| 185 | - public void joinClass(String username,String userpwd,boolean isShowPwd) { | ||
| 186 | - JoinClass joinClass=new JoinClass(); | 231 | + public void joinClass(String username, String userpwd, boolean isShowPwd) { |
| 232 | + JoinClass joinClass = new JoinClass(); | ||
| 187 | joinClass.setHasCamera(false); | 233 | joinClass.setHasCamera(false); |
| 188 | joinClass.setHasMicrophone(false); | 234 | joinClass.setHasMicrophone(false); |
| 189 | joinClass.setUserName(username); | 235 | joinClass.setUserName(username); |
| 190 | - if(!isShowPwd){ | 236 | + if (!isShowPwd) { |
| 191 | joinClass.setPassword("123321"); | 237 | joinClass.setPassword("123321"); |
| 192 | - }else{ | 238 | + } else { |
| 193 | joinClass.setPassword(userpwd); | 239 | joinClass.setPassword(userpwd); |
| 194 | } | 240 | } |
| 195 | - String temp=new Gson().toJson(joinClass); | 241 | + String temp = new Gson().toJson(joinClass); |
| 196 | String jsonParmp = XdyStringUtils.stringToJson(temp, true); | 242 | String jsonParmp = XdyStringUtils.stringToJson(temp, true); |
| 197 | XdyLogUtil.e("加入课堂", jsonParmp); | 243 | XdyLogUtil.e("加入课堂", jsonParmp); |
| 198 | xdySdk.api("joinClass", jsonParmp); | 244 | xdySdk.api("joinClass", jsonParmp); |
| @@ -200,24 +246,26 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -200,24 +246,26 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 200 | 246 | ||
| 201 | /** | 247 | /** |
| 202 | * 播放视频 | 248 | * 播放视频 |
| 249 | + * | ||
| 203 | * @param response | 250 | * @param response |
| 204 | */ | 251 | */ |
| 205 | public void playVideo(String response) { | 252 | public void playVideo(String response) { |
| 206 | - xdySdk.api("playVideo", response+"", surfaceviewPlayVideo, VideoPlayActivity.this); | 253 | + xdySdk.api("playVideo", response + "", surfaceviewPlayVideo, VideoPlayActivity.this); |
| 207 | // img_playVideo_novideo.setVisibility(View.GONE); | 254 | // img_playVideo_novideo.setVisibility(View.GONE); |
| 208 | img_playVideo_novideo.setImageResource(R.mipmap.no_video); | 255 | img_playVideo_novideo.setImageResource(R.mipmap.no_video); |
| 209 | - ToastUtil.showToastshort("视频播放初始化",VideoPlayActivity.this); | 256 | + ToastUtil.showToastshort("视频播放初始化", VideoPlayActivity.this); |
| 210 | } | 257 | } |
| 211 | 258 | ||
| 212 | /** | 259 | /** |
| 213 | * 播放音频 | 260 | * 播放音频 |
| 261 | + * | ||
| 214 | * @param response | 262 | * @param response |
| 215 | */ | 263 | */ |
| 216 | public void playAudio(String response) { | 264 | public void playAudio(String response) { |
| 217 | xdySdk.api("playAudio", response, null, VideoPlayActivity.this); | 265 | xdySdk.api("playAudio", response, null, VideoPlayActivity.this); |
| 218 | img_playVideo_novideo.setImageResource(R.mipmap.audio_mode); | 266 | img_playVideo_novideo.setImageResource(R.mipmap.audio_mode); |
| 219 | img_playVideo_novideo.setVisibility(View.VISIBLE); | 267 | img_playVideo_novideo.setVisibility(View.VISIBLE); |
| 220 | - ToastUtil.showToastshort("音频播放初始化",VideoPlayActivity.this); | 268 | + ToastUtil.showToastshort("音频播放初始化", VideoPlayActivity.this); |
| 221 | } | 269 | } |
| 222 | 270 | ||
| 223 | @Override | 271 | @Override |
| @@ -235,10 +283,13 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -235,10 +283,13 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 235 | @Override | 283 | @Override |
| 236 | public void onClick(DialogInterface dialogInterface, int i) { | 284 | public void onClick(DialogInterface dialogInterface, int i) { |
| 237 | xdySdk.onPlayDestroy(); | 285 | xdySdk.onPlayDestroy(); |
| 238 | - xdySdk.api("leaveClass",""); | 286 | + xdySdk.api("leaveClass", ""); |
| 287 | +// | ||
| 288 | +// xdySdk.remove(VideoPlayActivity.this); | ||
| 289 | + xdySdk.removeAll(); | ||
| 239 | UIUtils.closeDialog(mLoginDialog); | 290 | UIUtils.closeDialog(mLoginDialog); |
| 240 | - mHandler.removeCallbacksAndMessages(null); | ||
| 241 | - VideoPlayActivity.super.onBackPressed(); | 291 | +// VideoPlayActivity.super.onBackPressed(); |
| 292 | + Exit(); | ||
| 242 | 293 | ||
| 243 | } | 294 | } |
| 244 | }) | 295 | }) |
| @@ -250,15 +301,16 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -250,15 +301,16 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 250 | 301 | ||
| 251 | /** | 302 | /** |
| 252 | * 错误处理 | 303 | * 错误处理 |
| 304 | + * | ||
| 253 | * @param errorId | 305 | * @param errorId |
| 254 | * @param errorMsg | 306 | * @param errorMsg |
| 255 | */ | 307 | */ |
| 256 | - public void handError(String errorId,String errorMsg){ | ||
| 257 | - ErrorEntity errorEntity=JsonUtil.parseJsonToBean(errorMsg,ErrorEntity.class); | ||
| 258 | - if(errorEntity==null){ | 308 | + public void handError(String errorId, String errorMsg) { |
| 309 | + ErrorEntity errorEntity = JsonUtil.parseJsonToBean(errorMsg, ErrorEntity.class); | ||
| 310 | + if (errorEntity == null) { | ||
| 259 | return; | 311 | return; |
| 260 | } | 312 | } |
| 261 | - switch (errorEntity.getCode()+""){ | 313 | + switch (errorEntity.getCode() + "") { |
| 262 | case "100": | 314 | case "100": |
| 263 | case "101": | 315 | case "101": |
| 264 | case "102": | 316 | case "102": |
| @@ -276,17 +328,21 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -276,17 +328,21 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 276 | case "206": | 328 | case "206": |
| 277 | case "207": | 329 | case "207": |
| 278 | case "208": | 330 | case "208": |
| 279 | - ToastUtil.showToastshort(errorEntity.getReson(),this); | ||
| 280 | - Exit(); | 331 | + ToastUtil.showToastshort(errorEntity.getReson(), this); |
| 332 | + Exit(); | ||
| 333 | + break; | ||
| 334 | + case "300": | ||
| 335 | + case "301": | ||
| 336 | + progressDialogDismiss(); | ||
| 281 | break; | 337 | break; |
| 282 | case "10000": | 338 | case "10000": |
| 283 | - ToastUtil.showToastshort(errorEntity.getReson(),this); | 339 | + ToastUtil.showToastshort(errorEntity.getReson(), this); |
| 284 | break; | 340 | break; |
| 285 | case "10001": | 341 | case "10001": |
| 286 | - ToastUtil.showToastshort(errorEntity.getReson(),this); | 342 | + ToastUtil.showToastshort(errorEntity.getReson(), this); |
| 287 | break; | 343 | break; |
| 288 | case "20000": | 344 | case "20000": |
| 289 | - ToastUtil.showToastshort(errorEntity.getReson(),this); | 345 | + ToastUtil.showToastshort(errorEntity.getReson(), this); |
| 290 | break; | 346 | break; |
| 291 | } | 347 | } |
| 292 | 348 | ||
| @@ -296,34 +352,36 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -296,34 +352,36 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 296 | /** | 352 | /** |
| 297 | * 错误情况退出 | 353 | * 错误情况退出 |
| 298 | */ | 354 | */ |
| 299 | - public void Exit(){ | 355 | + public void Exit() { |
| 300 | xdySdk.remove(this); | 356 | xdySdk.remove(this); |
| 301 | UIUtils.closeDialog(mLoginDialog); | 357 | UIUtils.closeDialog(mLoginDialog); |
| 302 | - mHandler.removeCallbacksAndMessages(null); | 358 | +// mmHandler.removeCallbacksAndMessages(null); |
| 303 | this.finish(); | 359 | this.finish(); |
| 304 | } | 360 | } |
| 305 | 361 | ||
| 306 | - public void progressDialogDismiss(){ | ||
| 307 | - if(mProgressDialog!=null){ | 362 | + public void progressDialogDismiss() { |
| 363 | + if (mProgressDialog != null) { | ||
| 308 | mProgressDialog.dismiss(); | 364 | mProgressDialog.dismiss(); |
| 309 | } | 365 | } |
| 310 | } | 366 | } |
| 311 | - public void progressDialogShow(){ | ||
| 312 | - if(mProgressDialog==null){ | ||
| 313 | - mProgressDialog=ProgressDialog.show(VideoPlayActivity.this,"","加载中"); | ||
| 314 | - }else { | 367 | + |
| 368 | + public void progressDialogShow() { | ||
| 369 | + if (mProgressDialog == null) { | ||
| 370 | + mProgressDialog = ProgressDialog.show(VideoPlayActivity.this, "", "加载中"); | ||
| 371 | + } else { | ||
| 315 | mProgressDialog.show(); | 372 | mProgressDialog.show(); |
| 316 | } | 373 | } |
| 317 | } | 374 | } |
| 318 | 375 | ||
| 319 | /** | 376 | /** |
| 320 | * 停止播放 | 377 | * 停止播放 |
| 378 | + * | ||
| 321 | * @param response | 379 | * @param response |
| 322 | */ | 380 | */ |
| 323 | - public void stopPlay(String response){ | ||
| 324 | - VideoOrAudioStopEntity entity= JsonUtil.parseJsonToBean(response,VideoOrAudioStopEntity.class); | ||
| 325 | - if(entity!=null) { | ||
| 326 | - if(xdySdk.onPlayStop(entity.getMediaId()+"")){ | 381 | + public void stopPlay(String response) { |
| 382 | + VideoOrAudioStopEntity entity = JsonUtil.parseJsonToBean(response, VideoOrAudioStopEntity.class); | ||
| 383 | + if (entity != null) { | ||
| 384 | + if (xdySdk.onPlayStop(entity.getMediaId() + "")) { | ||
| 327 | img_playVideo_novideo.setImageResource(R.mipmap.novideo); | 385 | img_playVideo_novideo.setImageResource(R.mipmap.novideo); |
| 328 | img_playVideo_novideo.setVisibility(View.VISIBLE); | 386 | img_playVideo_novideo.setVisibility(View.VISIBLE); |
| 329 | } | 387 | } |
| @@ -332,12 +390,221 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | @@ -332,12 +390,221 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList | ||
| 332 | 390 | ||
| 333 | @Override | 391 | @Override |
| 334 | public void observerUpData(String type, String parameter) { | 392 | public void observerUpData(String type, String parameter) { |
| 335 | - XdyLogUtil.e(TAG+"observer:",Thread.currentThread().getId()+""); | ||
| 336 | - ResponseEntity responseEntity=new ResponseEntity(type,parameter); | ||
| 337 | - Message message=Message.obtain(); | ||
| 338 | - message.obj=responseEntity; | ||
| 339 | - mHandler.sendMessage(message); | 393 | + XdyLogUtil.e(TAG + "observer:", Thread.currentThread().getId() + ""); |
| 394 | + ResponseEntity responseEntity = new ResponseEntity(type, parameter); | ||
| 395 | + Message message = Message.obtain(); | ||
| 396 | + message.obj = responseEntity; | ||
| 397 | + mmHandler.sendMessage(message); | ||
| 340 | } | 398 | } |
| 341 | 399 | ||
| 400 | + /*************************************** 回放***************************************************/ | ||
| 401 | + private static final int FADE_OUT = 1; | ||
| 402 | + private static final int SHOW_PROGRESS = 2; | ||
| 403 | + private TextView mEndTime, mCurrentTime; | ||
| 404 | + private boolean mShowing; | ||
| 405 | + private boolean mDragging; | ||
| 406 | + private RelativeLayout mMediaControllerRight; | ||
| 407 | + | ||
| 408 | + // private PLMediaPlayer mMediaPlayer; | ||
| 409 | + private FrameLayout mMediaContainer; | ||
| 410 | + private ImageButton mPauseButton; | ||
| 411 | + private SeekBar mSeekBar; | ||
| 412 | + private RelativeLayout mPauseContainer; | ||
| 413 | + private TextView mClassName; | ||
| 414 | + private SurfaceView mSurfaceView = null; | ||
| 415 | + private AlertDialog mErrorDialog; | ||
| 416 | + @SuppressLint("HandlerLeak") | ||
| 417 | + private Handler mHandler = new Handler() { | ||
| 418 | + @Override | ||
| 419 | + public void handleMessage(Message msg) { | ||
| 420 | + switch (msg.what) { | ||
| 421 | + case FADE_OUT: | ||
| 422 | + hideMediaContainer(); | ||
| 423 | + break; | ||
| 424 | + case SHOW_PROGRESS: | ||
| 425 | + setProgress(); | ||
| 426 | + if (!mDragging && mShowing) { | ||
| 427 | + msg = obtainMessage(SHOW_PROGRESS); | ||
| 428 | + sendMessageDelayed(msg, 1000); | ||
| 429 | + updatePausePlay(); | ||
| 430 | + } | ||
| 431 | + break; | ||
| 432 | + } | ||
| 433 | + } | ||
| 434 | + }; | ||
| 435 | + public void initReplay() { | ||
| 436 | + mVideoView.setOnInfoListener(this); | ||
| 437 | + mVideoView.setOnErrorListener(this); | ||
| 438 | + mVideoView.setOnSeekCompleteListener(mOnSeekCompleteListener); | ||
| 439 | + mVideoView.setDisplayAspectRatio(PLVideoView.ASPECT_RATIO_PAVED_PARENT); | ||
| 440 | + AVOptions options = new AVOptions(); | ||
| 441 | + | ||
| 442 | + // 解码方式: | ||
| 443 | +// codec=AVOptions.MEDIA_CODEC_HW_DECODE,硬解 | ||
| 444 | +// codec=AVOptions.MEDIA_CODEC_SW_DECODE, 软解 | ||
| 445 | +// codec=AVOptions.MEDIA_CODEC_AUTO, 硬解优先,失败后自动切换到软解 | ||
| 446 | +// 默认值是:MEDIA_CODEC_SW_DECODE | ||
| 447 | + options.setInteger(AVOptions.KEY_MEDIACODEC, AVOptions.MEDIA_CODEC_AUTO); | ||
| 448 | + | ||
| 449 | +// 准备超时时间,包括创建资源、建立连接、请求码流等,单位是 ms | ||
| 450 | +// 默认值是:无 | ||
| 451 | + options.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000); | ||
| 452 | + | ||
| 453 | +// 读取视频流超时时间,单位是 ms | ||
| 454 | +// 默认值是:10 * 1000 | ||
| 455 | + options.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000); | ||
| 456 | + | ||
| 457 | +// 当前播放的是否为在线直播,如果是,则底层会有一些播放优化 | ||
| 458 | +// 默认值是:0为关闭 1为是 | ||
| 459 | + if (!replay) { | ||
| 460 | + options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1); | ||
| 461 | +// 是否开启"延时优化",只在在线直播流中有效 | ||
| 462 | +// 默认值是:0 | ||
| 463 | + options.setInteger(KEY_DELAY_OPTIMIZATION, 1); | ||
| 464 | + } else { | ||
| 465 | + XdyLogUtil.i(TAG, "回放设置AVOptions.KEY_LIVE_STREAMING, 0"); | ||
| 466 | + options.setInteger(AVOptions.KEY_LIVE_STREAMING, 0); | ||
| 467 | + } | ||
| 468 | +// 默认的缓存大小,单位是 ms | ||
| 469 | +// 默认值是:2000 | ||
| 470 | + options.setInteger(AVOptions.KEY_CACHE_BUFFER_DURATION, 300); | ||
| 471 | + | ||
| 472 | +// 最大的缓存大小,单位是 ms | ||
| 473 | +// 默认值是:4000 | ||
| 474 | + options.setInteger(AVOptions.KEY_MAX_CACHE_BUFFER_DURATION, 300); | ||
| 475 | +// 是否自动启动播放,如果设置为 1,则在调用 `prepareAsync` 或者 `setVideoPath` 之后自动启动播放,无需调用 `start()` | ||
| 476 | +// 默认值是:1 | ||
| 477 | + options.setInteger(AVOptions.KEY_START_ON_PREPARED, 0); | ||
| 478 | + | ||
| 479 | +// 播放前最大探测流的字节数,单位是 byte | ||
| 480 | +// 默认值是:128 * 1024 | ||
| 481 | + options.setInteger(AVOptions.KEY_PROBESIZE, 128 * 1024); | ||
| 482 | + options.setInteger(AVOptions.KEY_BUFFER_TIME, 300); | ||
| 342 | 483 | ||
| 484 | +// 请在开始播放之前配置 | ||
| 485 | + mVideoView.setAVOptions(options); | ||
| 486 | + } | ||
| 487 | + | ||
| 488 | + @Override | ||
| 489 | + public boolean onError(PLMediaPlayer plMediaPlayer, int i) { | ||
| 490 | + return false; | ||
| 491 | + } | ||
| 492 | + | ||
| 493 | + @Override | ||
| 494 | + public boolean onInfo(PLMediaPlayer plMediaPlayer, int i, int i1) { | ||
| 495 | +// boolean videoMode = mPresenter.isVideoMode(); | ||
| 496 | + | ||
| 497 | +// if (videoMode && PLMediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START == i) { | ||
| 498 | +//// initPic.setVisibility(View.INVISIBLE); | ||
| 499 | +// } | ||
| 500 | + return false; | ||
| 501 | + } | ||
| 502 | + | ||
| 503 | + private PLMediaPlayer.OnSeekCompleteListener mOnSeekCompleteListener = new PLMediaPlayer.OnSeekCompleteListener() { | ||
| 504 | + @Override | ||
| 505 | + public void onSeekComplete(PLMediaPlayer plMediaPlayer) { | ||
| 506 | + Log.d(TAG, "onSeekComplete !"); | ||
| 507 | + } | ||
| 508 | + }; | ||
| 509 | + | ||
| 510 | + | ||
| 511 | + | ||
| 512 | + | ||
| 513 | + private void setProgress() { | ||
| 514 | +// if (!mDragging) { | ||
| 515 | +// if (mEndTime != null) | ||
| 516 | +// mEndTime.setText(generateTime(mPresenter.getRecordPlaybackMaxTime())); | ||
| 517 | +// if (mCurrentTime != null) | ||
| 518 | +// mCurrentTime.setText(generateTime(mPresenter.getCurrentTime())); | ||
| 519 | +// if (mSeekBar != null) | ||
| 520 | +// mSeekBar.setProgress(mPresenter.getCurrentTime()); | ||
| 521 | +// } | ||
| 522 | + } | ||
| 523 | + | ||
| 524 | + private String generateTime(long currentTime) { | ||
| 525 | + int totalSeconds = (int) (currentTime); | ||
| 526 | + | ||
| 527 | + int seconds = totalSeconds % 60; | ||
| 528 | + int minutes = (totalSeconds / 60) % 60; | ||
| 529 | + int hours = totalSeconds / 3600; | ||
| 530 | + | ||
| 531 | + if (hours > 0) { | ||
| 532 | + return String.format(Locale.US, "%02d:%02d:%02d", hours, minutes, | ||
| 533 | + seconds).toString(); | ||
| 534 | + } else { | ||
| 535 | + return String.format(Locale.US, "%02d:%02d", minutes, seconds) | ||
| 536 | + .toString(); | ||
| 537 | + } | ||
| 538 | + } | ||
| 539 | + | ||
| 540 | + public void hideMediaContainer() { | ||
| 541 | + if (!mDragging && mShowing) { | ||
| 542 | + try { | ||
| 543 | + mHandler.removeMessages(SHOW_PROGRESS); | ||
| 544 | + mMediaContainer.setVisibility(View.GONE); | ||
| 545 | + } catch (IllegalArgumentException ex) { | ||
| 546 | + Log.d(TAG, "MediaController already removed"); | ||
| 547 | + } | ||
| 548 | + mShowing = false; | ||
| 549 | + } | ||
| 550 | + } | ||
| 551 | + | ||
| 552 | + public void updatePausePlay() { | ||
| 553 | +// if (mPresenter.getRecordStatus()) | ||
| 554 | +// mPauseButton.setImageResource(play); | ||
| 555 | +// else | ||
| 556 | +// mPauseButton.setImageResource(R.mipmap.stop); | ||
| 557 | +// } | ||
| 558 | + } | ||
| 559 | + | ||
| 560 | + private void handleRecord(String pa) { | ||
| 561 | + try { | ||
| 562 | + JSONObject jsonObject = new JSONObject(pa); | ||
| 563 | + int status = jsonObject.optInt("status"); | ||
| 564 | + switch (status) { | ||
| 565 | + case Constants.RECORD_READY: | ||
| 566 | +// pause = true; | ||
| 567 | +// isOver = false; | ||
| 568 | + break; | ||
| 569 | + case Constants.RECORD_PLAYING: | ||
| 570 | +// pause = false; | ||
| 571 | +// isOver = false; | ||
| 572 | +// mRootView.pauseOrStartEverything(); | ||
| 573 | + break; | ||
| 574 | + case Constants.RECORD_SEEK: | ||
| 575 | +// isOver = false; | ||
| 576 | +// pause = false; | ||
| 577 | +// int keyFrameSeek = jsonObject.optInt("keyFrameSeekTime"); | ||
| 578 | +// mRootView.seek(keyFrameSeek); | ||
| 579 | + break; | ||
| 580 | + case Constants.RECORD_STOP: | ||
| 581 | +// pause = true; | ||
| 582 | +// //停止后 录制回放要进行初始化 | ||
| 583 | +// if (!quit) {//回放结束了 | ||
| 584 | +// isOver = true; | ||
| 585 | +// if (currentTime < recordPlaybackMaxTime) | ||
| 586 | +// currentTime++; | ||
| 587 | +// int classId = AccountUtils.getUser().getClassId(); | ||
| 588 | +// mModel.initRecordPlayback(classId, portal, userRole, userId); | ||
| 589 | +// //停止视频 | ||
| 590 | +// mRootView.stopVideo(); | ||
| 591 | +// currentTime = 0; | ||
| 592 | +// mRootView.resetSeekBar(); | ||
| 593 | +// docView.clear(); | ||
| 594 | +// chatView.clearChatHistory(); | ||
| 595 | +// currentPlayAudio = null; | ||
| 596 | +// currentPlayVideo = null; | ||
| 597 | +// } | ||
| 598 | + break; | ||
| 599 | + case Constants.RECORD_PAUSE: | ||
| 600 | +// isOver = false; | ||
| 601 | +// pause = true; | ||
| 602 | +// mRootView.pauseOrStartEverything(); | ||
| 603 | + break; | ||
| 604 | + } | ||
| 605 | +// mRootView.updatePausePlay(); | ||
| 606 | + } catch (JSONException e) { | ||
| 607 | + e.printStackTrace(); | ||
| 608 | + } | ||
| 609 | + } | ||
| 343 | } | 610 | } |
| @@ -26,9 +26,13 @@ import android.widget.RelativeLayout; | @@ -26,9 +26,13 @@ import android.widget.RelativeLayout; | ||
| 26 | import android.widget.TextView; | 26 | import android.widget.TextView; |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | +import com.mang.xdy.common.Constants; | ||
| 30 | +import com.mang.xdy.core.SPUtil; | ||
| 29 | import com.mang.xdy.demo.R; | 31 | import com.mang.xdy.demo.R; |
| 32 | +import com.mang.xdy.demo.bean.JoinClassSuccessEntity; | ||
| 30 | import com.mang.xdy.demo.bean.Message; | 33 | import com.mang.xdy.demo.bean.Message; |
| 31 | import com.mang.xdy.demo.fragment.ChatFragment; | 34 | import com.mang.xdy.demo.fragment.ChatFragment; |
| 35 | +import com.mang.xdy.demo.utils.JsonUtil; | ||
| 32 | import com.mang.xdy.demo.widget.chat.UrlUtils; | 36 | import com.mang.xdy.demo.widget.chat.UrlUtils; |
| 33 | import com.mang.xdy.utils.XdyLogUtil; | 37 | import com.mang.xdy.utils.XdyLogUtil; |
| 34 | 38 | ||
| @@ -47,7 +51,7 @@ public class ChatAdapter extends BaseAdapter { | @@ -47,7 +51,7 @@ public class ChatAdapter extends BaseAdapter { | ||
| 47 | private KJBitmap kjb; | 51 | private KJBitmap kjb; |
| 48 | private ChatFragment.OnChatItemClickListener listener; | 52 | private ChatFragment.OnChatItemClickListener listener; |
| 49 | String oldTime; | 53 | String oldTime; |
| 50 | - | 54 | + String userRole=""; |
| 51 | public ChatAdapter(Context cxt, List<Message> datas, ChatFragment.OnChatItemClickListener listener) { | 55 | public ChatAdapter(Context cxt, List<Message> datas, ChatFragment.OnChatItemClickListener listener) { |
| 52 | this.cxt = cxt; | 56 | this.cxt = cxt; |
| 53 | if (datas == null) { | 57 | if (datas == null) { |
| @@ -56,6 +60,7 @@ public class ChatAdapter extends BaseAdapter { | @@ -56,6 +60,7 @@ public class ChatAdapter extends BaseAdapter { | ||
| 56 | this.datas = datas; | 60 | this.datas = datas; |
| 57 | kjb = new KJBitmap(); | 61 | kjb = new KJBitmap(); |
| 58 | this.listener = listener; | 62 | this.listener = listener; |
| 63 | + getUserRole(cxt); | ||
| 59 | } | 64 | } |
| 60 | 65 | ||
| 61 | public void refresh(List<Message> datas) { | 66 | public void refresh(List<Message> datas) { |
| @@ -158,53 +163,52 @@ public class ChatAdapter extends BaseAdapter { | @@ -158,53 +163,52 @@ public class ChatAdapter extends BaseAdapter { | ||
| 158 | kjb.display(holder.img_avatar, data.getToUserAvatar()); | 163 | kjb.display(holder.img_avatar, data.getToUserAvatar()); |
| 159 | }*/ | 164 | }*/ |
| 160 | if (data.getIsSend()) { | 165 | if (data.getIsSend()) { |
| 161 | - XdyLogUtil.e("chatadapter getIsSend","hahhaahahhaahhhahaahahha"); | ||
| 162 | -// switch (AccountUtils.getUser().getUserRole()) { | ||
| 163 | -// case "normal"://普通角色/学生 | ||
| 164 | -// if (!TextUtils.isEmpty(data.getFromUserName())) { | ||
| 165 | -// holder.tv_name.setText(data.getFromUserName()); | ||
| 166 | -// } else { | ||
| 167 | -// holder.tv_name.setText("学生"); | ||
| 168 | -// } | ||
| 169 | -// holder.tv_teacher_bg.setVisibility(View.GONE); | ||
| 170 | -// holder.img_avatar.setImageResource(R.mipmap.student); | ||
| 171 | -// break; | ||
| 172 | -// case "host"://主持人/老师 | ||
| 173 | -// if (TextUtils.isEmpty(data.getFromUserName())) { | ||
| 174 | -// data.setFromUserName("老师"); | ||
| 175 | -// } | ||
| 176 | -// holder.img_avatar.setImageResource(R.mipmap.teacher); | ||
| 177 | -// holder.tv_name.setText(data.getFromUserName()); | ||
| 178 | -// holder.tv_teacher_bg.setVisibility(View.VISIBLE); | ||
| 179 | -// break; | ||
| 180 | -// case "presenter"://主讲人 | ||
| 181 | -// if (!TextUtils.isEmpty(data.getFromUserName())) { | ||
| 182 | -// holder.tv_name.setText(data.getFromUserName()); | ||
| 183 | -// } else { | ||
| 184 | -// holder.tv_name.setText("主讲人"); | ||
| 185 | -// } | ||
| 186 | -// holder.tv_teacher_bg.setVisibility(View.GONE); | ||
| 187 | -// holder.img_avatar.setImageResource(R.mipmap.student); | ||
| 188 | -// break; | ||
| 189 | -// case "assistant"://助教 | ||
| 190 | -// if (!TextUtils.isEmpty(data.getFromUserName())) { | ||
| 191 | -// holder.tv_name.setText(data.getFromUserName()); | ||
| 192 | -// } else { | ||
| 193 | -// holder.tv_name.setText("助教"); | ||
| 194 | -// } | ||
| 195 | -// holder.tv_teacher_bg.setVisibility(View.GONE); | ||
| 196 | -// holder.img_avatar.setImageResource(R.mipmap.student); | ||
| 197 | -// break; | ||
| 198 | -// case "record":// 暂时没用 | ||
| 199 | -// if (!TextUtils.isEmpty(data.getFromUserName())) { | ||
| 200 | -// holder.tv_name.setText(data.getFromUserName()); | ||
| 201 | -// } else { | ||
| 202 | -// holder.tv_name.setText("学生"); | ||
| 203 | -// } | ||
| 204 | -// holder.tv_teacher_bg.setVisibility(View.GONE); | ||
| 205 | -// holder.img_avatar.setImageResource(R.mipmap.student); | ||
| 206 | -// break; | ||
| 207 | -// } | 166 | + switch (userRole) { |
| 167 | + case "normal"://普通角色/学生 | ||
| 168 | + if (!TextUtils.isEmpty(data.getFromUserName())) { | ||
| 169 | + holder.tv_name.setText(data.getFromUserName()); | ||
| 170 | + } else { | ||
| 171 | + holder.tv_name.setText("学生"); | ||
| 172 | + } | ||
| 173 | + holder.tv_teacher_bg.setVisibility(View.GONE); | ||
| 174 | + holder.img_avatar.setImageResource(R.mipmap.student); | ||
| 175 | + break; | ||
| 176 | + case "host"://主持人/老师 | ||
| 177 | + if (TextUtils.isEmpty(data.getFromUserName())) { | ||
| 178 | + data.setFromUserName("老师"); | ||
| 179 | + } | ||
| 180 | + holder.img_avatar.setImageResource(R.mipmap.teacher); | ||
| 181 | + holder.tv_name.setText(data.getFromUserName()); | ||
| 182 | + holder.tv_teacher_bg.setVisibility(View.VISIBLE); | ||
| 183 | + break; | ||
| 184 | + case "presenter"://主讲人 | ||
| 185 | + if (!TextUtils.isEmpty(data.getFromUserName())) { | ||
| 186 | + holder.tv_name.setText(data.getFromUserName()); | ||
| 187 | + } else { | ||
| 188 | + holder.tv_name.setText("主讲人"); | ||
| 189 | + } | ||
| 190 | + holder.tv_teacher_bg.setVisibility(View.GONE); | ||
| 191 | + holder.img_avatar.setImageResource(R.mipmap.student); | ||
| 192 | + break; | ||
| 193 | + case "assistant"://助教 | ||
| 194 | + if (!TextUtils.isEmpty(data.getFromUserName())) { | ||
| 195 | + holder.tv_name.setText(data.getFromUserName()); | ||
| 196 | + } else { | ||
| 197 | + holder.tv_name.setText("助教"); | ||
| 198 | + } | ||
| 199 | + holder.tv_teacher_bg.setVisibility(View.GONE); | ||
| 200 | + holder.img_avatar.setImageResource(R.mipmap.student); | ||
| 201 | + break; | ||
| 202 | + case "record":// 暂时没用 | ||
| 203 | + if (!TextUtils.isEmpty(data.getFromUserName())) { | ||
| 204 | + holder.tv_name.setText(data.getFromUserName()); | ||
| 205 | + } else { | ||
| 206 | + holder.tv_name.setText("学生"); | ||
| 207 | + } | ||
| 208 | + holder.tv_teacher_bg.setVisibility(View.GONE); | ||
| 209 | + holder.img_avatar.setImageResource(R.mipmap.student); | ||
| 210 | + break; | ||
| 211 | + } | ||
| 208 | } | 212 | } |
| 209 | else { | 213 | else { |
| 210 | switch (data.getUserRole()) { | 214 | switch (data.getUserRole()) { |
| @@ -311,4 +315,11 @@ public class ChatAdapter extends BaseAdapter { | @@ -311,4 +315,11 @@ public class ChatAdapter extends BaseAdapter { | ||
| 311 | final float scale = cxt.getResources().getDisplayMetrics().scaledDensity; | 315 | final float scale = cxt.getResources().getDisplayMetrics().scaledDensity; |
| 312 | return spValue * scale; | 316 | return spValue * scale; |
| 313 | } | 317 | } |
| 318 | + | ||
| 319 | + public void getUserRole(Context context){ | ||
| 320 | + JoinClassSuccessEntity joinClassSuccessEntity= JsonUtil.parseJsonToBean(SPUtil.getString(context, Constants.CLASS_JOIN_SUCCESS,""),JoinClassSuccessEntity.class); | ||
| 321 | + if(joinClassSuccessEntity!=null) { | ||
| 322 | + userRole = joinClassSuccessEntity.getUserRole() ; | ||
| 323 | + } | ||
| 324 | + } | ||
| 314 | } | 325 | } |
| @@ -21,13 +21,13 @@ public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter { | @@ -21,13 +21,13 @@ public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter { | ||
| 21 | private String tabTitles[] = new String[]{"文档","聊天"}; | 21 | private String tabTitles[] = new String[]{"文档","聊天"}; |
| 22 | private Context context; | 22 | private Context context; |
| 23 | private DocFragment docFragment=new DocFragment(); | 23 | private DocFragment docFragment=new DocFragment(); |
| 24 | -// private ChatFragment chatFragment=new ChatFragment(); | 24 | + private ChatFragment chatFragment=new ChatFragment(); |
| 25 | private List<Fragment> fragmentList=new ArrayList<>(); | 25 | private List<Fragment> fragmentList=new ArrayList<>(); |
| 26 | public SimpleFragmentPagerAdapter(FragmentManager fm,Context context) { | 26 | public SimpleFragmentPagerAdapter(FragmentManager fm,Context context) { |
| 27 | super(fm); | 27 | super(fm); |
| 28 | this.context = context; | 28 | this.context = context; |
| 29 | fragmentList.add(docFragment); | 29 | fragmentList.add(docFragment); |
| 30 | -// fragmentList.add(chatFragment); | 30 | + fragmentList.add(chatFragment); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | @Override | 33 | @Override |
| @@ -2,6 +2,7 @@ package com.mang.xdy.demo.fragment; | @@ -2,6 +2,7 @@ package com.mang.xdy.demo.fragment; | ||
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | +import android.os.Handler; | ||
| 5 | import android.support.annotation.Nullable; | 6 | import android.support.annotation.Nullable; |
| 6 | import android.support.v4.app.Fragment; | 7 | import android.support.v4.app.Fragment; |
| 7 | import android.text.Selection; | 8 | import android.text.Selection; |
| @@ -88,6 +89,7 @@ public class ChatFragment extends Fragment implements ObserverListener{ | @@ -88,6 +89,7 @@ public class ChatFragment extends Fragment implements ObserverListener{ | ||
| 88 | // LogUtil.i("聊天内容===" + content); | 89 | // LogUtil.i("聊天内容===" + content); |
| 89 | // mPresenter.sendChatMsg(content, 0); | 90 | // mPresenter.sendChatMsg(content, 0); |
| 90 | sendMeg(content); | 91 | sendMeg(content); |
| 92 | + box.hideKeyboard(mContext); | ||
| 91 | } | 93 | } |
| 92 | 94 | ||
| 93 | } | 95 | } |
| @@ -183,7 +185,7 @@ public class ChatFragment extends Fragment implements ObserverListener{ | @@ -183,7 +185,7 @@ public class ChatFragment extends Fragment implements ObserverListener{ | ||
| 183 | JoinClassSuccessEntity joinClassSuccessEntity=JsonUtil.parseJsonToBean(SPUtil.getString(mContext,Constants.CLASS_JOIN_SUCCESS,""),JoinClassSuccessEntity.class); | 185 | JoinClassSuccessEntity joinClassSuccessEntity=JsonUtil.parseJsonToBean(SPUtil.getString(mContext,Constants.CLASS_JOIN_SUCCESS,""),JoinClassSuccessEntity.class); |
| 184 | String nodeId=""; | 186 | String nodeId=""; |
| 185 | if(joinClassSuccessEntity!=null) { | 187 | if(joinClassSuccessEntity!=null) { |
| 186 | - nodeId = joinClassSuccessEntity.getNodeId() + ""; | 188 | + nodeId = joinClassSuccessEntity.getNodeId() + ""; |
| 187 | } | 189 | } |
| 188 | if (entity != null && adapter != null) { | 190 | if (entity != null && adapter != null) { |
| 189 | Message message; | 191 | Message message; |
| @@ -253,12 +255,23 @@ public class ChatFragment extends Fragment implements ObserverListener{ | @@ -253,12 +255,23 @@ public class ChatFragment extends Fragment implements ObserverListener{ | ||
| 253 | }; | 255 | }; |
| 254 | } | 256 | } |
| 255 | 257 | ||
| 256 | - | 258 | +private Handler mHandler=new Handler(){ |
| 259 | + @Override | ||
| 260 | + public void handleMessage(android.os.Message msg) { | ||
| 261 | + super.handleMessage(msg); | ||
| 262 | + } | ||
| 263 | +}; | ||
| 257 | @Override | 264 | @Override |
| 258 | - public void observerUpData(String type, String parameter) { | 265 | + public void observerUpData(String type, final String parameter) { |
| 259 | switch (type) { | 266 | switch (type) { |
| 260 | case Constants.CHAT_RECEIVE_MESSAGE: | 267 | case Constants.CHAT_RECEIVE_MESSAGE: |
| 261 | - renderChatMsg(parameter); | 268 | + mHandler.post(new Runnable() { |
| 269 | + @Override | ||
| 270 | + public void run() { | ||
| 271 | + renderChatMsg(parameter); | ||
| 272 | + } | ||
| 273 | + }); | ||
| 274 | + | ||
| 262 | break; | 275 | break; |
| 263 | } | 276 | } |
| 264 | } | 277 | } |
| @@ -8,20 +8,18 @@ import android.os.Handler; | @@ -8,20 +8,18 @@ import android.os.Handler; | ||
| 8 | import android.os.Message; | 8 | import android.os.Message; |
| 9 | import android.support.annotation.Nullable; | 9 | import android.support.annotation.Nullable; |
| 10 | import android.support.v4.app.Fragment; | 10 | import android.support.v4.app.Fragment; |
| 11 | +import android.text.TextUtils; | ||
| 11 | import android.util.DisplayMetrics; | 12 | import android.util.DisplayMetrics; |
| 12 | import android.view.LayoutInflater; | 13 | import android.view.LayoutInflater; |
| 13 | import android.view.View; | 14 | import android.view.View; |
| 14 | import android.view.ViewGroup; | 15 | import android.view.ViewGroup; |
| 15 | 16 | ||
| 16 | import com.bumptech.glide.Glide; | 17 | import com.bumptech.glide.Glide; |
| 17 | -import com.google.gson.Gson; | ||
| 18 | import com.mang.xdy.common.Constants; | 18 | import com.mang.xdy.common.Constants; |
| 19 | import com.mang.xdy.core.XdySdk; | 19 | import com.mang.xdy.core.XdySdk; |
| 20 | import com.mang.xdy.demo.R; | 20 | import com.mang.xdy.demo.R; |
| 21 | -import com.mang.xdy.demo.activity.VideoPlayActivity; | ||
| 22 | import com.mang.xdy.demo.base.BaseRunnable; | 21 | import com.mang.xdy.demo.base.BaseRunnable; |
| 23 | import com.mang.xdy.demo.bean.DocEntity; | 22 | import com.mang.xdy.demo.bean.DocEntity; |
| 24 | -import com.mang.xdy.demo.bean.GetDocImageEntity; | ||
| 25 | import com.mang.xdy.demo.bean.WhiteboardUpdateEntity; | 23 | import com.mang.xdy.demo.bean.WhiteboardUpdateEntity; |
| 26 | import com.mang.xdy.demo.bean.WrapDocBitMapEntity; | 24 | import com.mang.xdy.demo.bean.WrapDocBitMapEntity; |
| 27 | import com.mang.xdy.demo.utils.JsonUtil; | 25 | import com.mang.xdy.demo.utils.JsonUtil; |
| @@ -29,8 +27,8 @@ import com.mang.xdy.demo.utils.ToastUtil; | @@ -29,8 +27,8 @@ import com.mang.xdy.demo.utils.ToastUtil; | ||
| 29 | import com.mang.xdy.demo.widget.CanvasView; | 27 | import com.mang.xdy.demo.widget.CanvasView; |
| 30 | import com.mang.xdy.listener.ObserverListener; | 28 | import com.mang.xdy.listener.ObserverListener; |
| 31 | import com.mang.xdy.utils.XdyLogUtil; | 29 | import com.mang.xdy.utils.XdyLogUtil; |
| 32 | -import com.mang.xdy.utils.XdyStringUtils; | ||
| 33 | -import com.squareup.picasso.Picasso; | 30 | + |
| 31 | +import org.json.JSONObject; | ||
| 34 | 32 | ||
| 35 | import java.util.concurrent.ExecutionException; | 33 | import java.util.concurrent.ExecutionException; |
| 36 | 34 | ||
| @@ -56,6 +54,8 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -56,6 +54,8 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 56 | int winWidth; | 54 | int winWidth; |
| 57 | int winHeight; | 55 | int winHeight; |
| 58 | private long intervalTime; | 56 | private long intervalTime; |
| 57 | + /*判断文档和白板是否匹配*/ | ||
| 58 | + private String mItemidx =""; | ||
| 59 | 59 | ||
| 60 | @Override | 60 | @Override |
| 61 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { | 61 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { |
| @@ -105,6 +105,7 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -105,6 +105,7 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 105 | if (docEntity != null && docEntity.isVisible()==true&&docEntity.getImages()!= null&&docEntity.getImages().size()>=1) { | 105 | if (docEntity != null && docEntity.isVisible()==true&&docEntity.getImages()!= null&&docEntity.getImages().size()>=1) { |
| 106 | int currentPic=docEntity.getCurPageNo(); | 106 | int currentPic=docEntity.getCurPageNo(); |
| 107 | setDocImage(docEntity.getImages().get((currentPic>0) ? currentPic-1:0)); | 107 | setDocImage(docEntity.getImages().get((currentPic>0) ? currentPic-1:0)); |
| 108 | + mItemidx = docEntity.getItemIdx()+""; | ||
| 108 | } | 109 | } |
| 109 | } | 110 | } |
| 110 | 111 | ||
| @@ -150,6 +151,9 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -150,6 +151,9 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 150 | public void showDoc(String type,String response){ | 151 | public void showDoc(String type,String response){ |
| 151 | WhiteboardUpdateEntity whiteboardUpdateEntity= JsonUtil.parseJsonToBean(response,WhiteboardUpdateEntity.class); | 152 | WhiteboardUpdateEntity whiteboardUpdateEntity= JsonUtil.parseJsonToBean(response,WhiteboardUpdateEntity.class); |
| 152 | if(whiteboardUpdateEntity!=null){ | 153 | if(whiteboardUpdateEntity!=null){ |
| 154 | + if(whiteboardUpdateEntity.annotaionItems!=null){ | ||
| 155 | + if (whiteboardUpdateEntity.annotaionItems.size()>0&& mItemidx.equals(whiteboardUpdateEntity.annotaionItems.get(0).parentId)){ | ||
| 156 | + | ||
| 153 | if (intervalTime != 0) { | 157 | if (intervalTime != 0) { |
| 154 | intervalTime = System.currentTimeMillis() - intervalTime; | 158 | intervalTime = System.currentTimeMillis() - intervalTime; |
| 155 | if (intervalTime < 150) {//小于100毫秒 不执行? | 159 | if (intervalTime < 150) {//小于100毫秒 不执行? |
| @@ -161,7 +165,8 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -161,7 +165,8 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 161 | } | 165 | } |
| 162 | intervalTime = System.currentTimeMillis(); | 166 | intervalTime = System.currentTimeMillis(); |
| 163 | } | 167 | } |
| 164 | - | 168 | + } |
| 169 | + } | ||
| 165 | } | 170 | } |
| 166 | private void delayDraw(final WhiteboardUpdateEntity entity) { | 171 | private void delayDraw(final WhiteboardUpdateEntity entity) { |
| 167 | 172 | ||
| @@ -244,7 +249,7 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -244,7 +249,7 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 244 | }); | 249 | }); |
| 245 | } | 250 | } |
| 246 | @Override | 251 | @Override |
| 247 | - public void observerUpData(String type, String parameter) { | 252 | + public void observerUpData(final String type, final String parameter) { |
| 248 | XdyLogUtil.e(TAG,"type:"+type+" response:"+parameter); | 253 | XdyLogUtil.e(TAG,"type:"+type+" response:"+parameter); |
| 249 | switch (type){ | 254 | switch (type){ |
| 250 | case Constants.DOCUMENT_UPDATE: | 255 | case Constants.DOCUMENT_UPDATE: |
| @@ -254,7 +259,16 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -254,7 +259,16 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 254 | showDoc(type,parameter); | 259 | showDoc(type,parameter); |
| 255 | break; | 260 | break; |
| 256 | case Constants.DOCUMENT_DELETE: | 261 | case Constants.DOCUMENT_DELETE: |
| 257 | - docUrlTransformBitmap(null); | 262 | + try { |
| 263 | + JSONObject object = new JSONObject(parameter); | ||
| 264 | + String itemIdx = object.optInt("itemIdx")+""; | ||
| 265 | + if (!TextUtils.isEmpty(itemIdx)&& mItemidx.equals(itemIdx)){ | ||
| 266 | + docUrlTransformBitmap(null); | ||
| 267 | + } | ||
| 268 | + } catch (Exception e) { | ||
| 269 | + e.printStackTrace(); | ||
| 270 | + } | ||
| 271 | + | ||
| 258 | break; | 272 | break; |
| 259 | 273 | ||
| 260 | } | 274 | } |
| @@ -263,6 +277,12 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -263,6 +277,12 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 263 | public void onDestroyView() { | 277 | public void onDestroyView() { |
| 264 | super.onDestroyView(); | 278 | super.onDestroyView(); |
| 265 | xdySdk.remove(this); | 279 | xdySdk.remove(this); |
| 280 | + if(mCanvasView!=null){ | ||
| 281 | + mCanvasView.clear(); | ||
| 282 | + } | ||
| 283 | + if(bitmap!=null){ | ||
| 284 | + bitmap=null; | ||
| 285 | + } | ||
| 266 | mHandler.removeCallbacksAndMessages(null); | 286 | mHandler.removeCallbacksAndMessages(null); |
| 267 | } | 287 | } |
| 268 | } | 288 | } |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layer-list | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:id="@android:id/background"> | ||
| 5 | + <shape> | ||
| 6 | + <size android:height="@dimen/ui_DIMEN_2.0PX"/> | ||
| 7 | + <solid android:color="#f2f2f2"/> | ||
| 8 | + </shape> | ||
| 9 | + </item> | ||
| 10 | + <item android:id="@android:id/secondaryProgress"> | ||
| 11 | + <clip> | ||
| 12 | + <shape> | ||
| 13 | + <size android:height="@dimen/ui_DIMEN_2.0PX"/> | ||
| 14 | + <solid android:color="#f2f2f2"/> | ||
| 15 | + </shape> | ||
| 16 | + </clip> | ||
| 17 | + </item> | ||
| 18 | + <item android:id="@android:id/progress"> | ||
| 19 | + <clip> | ||
| 20 | + <shape> | ||
| 21 | + <size android:height="@dimen/ui_DIMEN_2.0PX"/> | ||
| 22 | + <solid android:color="#f55c22"/> | ||
| 23 | + </shape> | ||
| 24 | + </clip> | ||
| 25 | + </item> | ||
| 26 | +</layer-list> |
| @@ -6,6 +6,18 @@ | @@ -6,6 +6,18 @@ | ||
| 6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
| 7 | android:orientation="vertical" | 7 | android:orientation="vertical" |
| 8 | tools:context="com.mang.xdy.demo.activity.VideoPlayActivity"> | 8 | tools:context="com.mang.xdy.demo.activity.VideoPlayActivity"> |
| 9 | + | ||
| 10 | + <FrameLayout | ||
| 11 | + android:id="@+id/fl_videoview_container" | ||
| 12 | + android:layout_width="match_parent" | ||
| 13 | + android:layout_height="10dp"> | ||
| 14 | + | ||
| 15 | + <com.pili.pldroid.player.widget.PLVideoTextureView | ||
| 16 | + android:id="@+id/img_playVideo_replay" | ||
| 17 | + android:layout_width="match_parent" | ||
| 18 | + android:layout_height="match_parent" | ||
| 19 | + android:layout_gravity="center"/> | ||
| 20 | + </FrameLayout> | ||
| 9 | <RelativeLayout | 21 | <RelativeLayout |
| 10 | android:layout_width="match_parent" | 22 | android:layout_width="match_parent" |
| 11 | android:layout_height="@dimen/ui_DIMEN_500.0PX"> | 23 | android:layout_height="@dimen/ui_DIMEN_500.0PX"> |
| @@ -20,6 +32,12 @@ | @@ -20,6 +32,12 @@ | ||
| 20 | android:background="@mipmap/novideo" | 32 | android:background="@mipmap/novideo" |
| 21 | /> | 33 | /> |
| 22 | </RelativeLayout> | 34 | </RelativeLayout> |
| 35 | +<Button | ||
| 36 | + android:id="@+id/btn_videoPlay_exit" | ||
| 37 | + android:layout_width="wrap_content" | ||
| 38 | + android:layout_height="wrap_content" | ||
| 39 | + android:text="退出课堂,界面还在" | ||
| 40 | + /> | ||
| 23 | <android.support.design.widget.TabLayout | 41 | <android.support.design.widget.TabLayout |
| 24 | android:id="@+id/sliding_tabs" | 42 | android:id="@+id/sliding_tabs" |
| 25 | android:layout_width="match_parent" | 43 | android:layout_width="match_parent" |
| @@ -32,4 +50,16 @@ | @@ -32,4 +50,16 @@ | ||
| 32 | android:layout_height="0px" | 50 | android:layout_height="0px" |
| 33 | android:layout_weight="1" | 51 | android:layout_weight="1" |
| 34 | android:background="@android:color/white" /> | 52 | android:background="@android:color/white" /> |
| 53 | + <FrameLayout | ||
| 54 | + android:id="@+id/fl_media" | ||
| 55 | + android:layout_width="match_parent" | ||
| 56 | + android:layout_height="wrap_content" | ||
| 57 | + android:layout_alignParentBottom="true" | ||
| 58 | + android:visibility="invisible"> | ||
| 59 | + | ||
| 60 | + <include | ||
| 61 | + layout="@layout/home_media_controller" | ||
| 62 | + android:layout_width="match_parent" | ||
| 63 | + android:layout_height="wrap_content"/> | ||
| 64 | + </FrameLayout> | ||
| 35 | </LinearLayout> | 65 | </LinearLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 4 | + android:layout_width="match_parent" | ||
| 5 | + android:layout_height="wrap_content"> | ||
| 6 | + | ||
| 7 | + <ImageView | ||
| 8 | + android:layout_width="match_parent" | ||
| 9 | + android:layout_height="wrap_content" | ||
| 10 | + android:background="@mipmap/gradient_play"/> | ||
| 11 | + | ||
| 12 | + <RelativeLayout | ||
| 13 | + android:paddingLeft="@dimen/ui_DIMEN_20.0PX" | ||
| 14 | + android:id="@+id/rl_operation_play" | ||
| 15 | + android:layout_width="@dimen/ui_DIMEN_70.0PX" | ||
| 16 | + android:layout_centerVertical="true" | ||
| 17 | + android:layout_height="@dimen/ui_DIMEN_70.0PX"> | ||
| 18 | + | ||
| 19 | + <ImageButton | ||
| 20 | + android:layout_marginLeft="@dimen/ui_DIMEN_20.0PX" | ||
| 21 | + android:id="@+id/iv_operation_play" | ||
| 22 | + android:layout_width="wrap_content" | ||
| 23 | + android:layout_centerInParent="true" | ||
| 24 | + android:layout_height="wrap_content" | ||
| 25 | + android:background="@null" | ||
| 26 | + android:src="@mipmap/play"/> | ||
| 27 | + | ||
| 28 | + </RelativeLayout> | ||
| 29 | + <RelativeLayout | ||
| 30 | + android:id="@+id/rl_meadia_contriller_right" | ||
| 31 | + android:gravity="center" | ||
| 32 | + android:layout_toRightOf="@id/rl_operation_play" | ||
| 33 | + android:layout_width="match_parent" | ||
| 34 | + android:layout_marginTop="@dimen/ui_DIMEN_6.0PX" | ||
| 35 | + android:layout_height="@dimen/ui_DIMEN_70.0PX"> | ||
| 36 | + <TextView | ||
| 37 | + android:id="@+id/tv_current_time" | ||
| 38 | + style="@style/ui_wrapTvBaseStyle" | ||
| 39 | + android:minWidth="@dimen/ui_DIMEN_100.0PX" | ||
| 40 | + android:textColor="@color/white" | ||
| 41 | + android:gravity="end" | ||
| 42 | + tools:text="12:00:12"/> | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + <TextView | ||
| 47 | + android:id="@+id/tv_end_time" | ||
| 48 | + style="@style/ui_wrapTvBaseStyle" | ||
| 49 | + android:layout_alignParentRight="true" | ||
| 50 | + android:layout_marginRight="@dimen/ui_DIMEN_30.0PX" | ||
| 51 | + android:textColor="@color/white" | ||
| 52 | + tools:text="12:00"/> | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + <SeekBar | ||
| 56 | + android:id="@+id/sb_live" | ||
| 57 | + style="@style/home_seek_bar" | ||
| 58 | + android:layout_width="match_parent" | ||
| 59 | + android:layout_height="wrap_content" | ||
| 60 | + android:layout_toLeftOf="@id/tv_end_time" | ||
| 61 | + android:layout_toRightOf="@id/tv_current_time"/> | ||
| 62 | + </RelativeLayout> | ||
| 63 | + | ||
| 64 | + | ||
| 65 | +</RelativeLayout> |
| @@ -105,4 +105,11 @@ | @@ -105,4 +105,11 @@ | ||
| 105 | <item name="android:textColor">@color/white</item> | 105 | <item name="android:textColor">@color/white</item> |
| 106 | <item name="android:textSize">@dimen/ui_DIMEN_34.0PX</item> | 106 | <item name="android:textSize">@dimen/ui_DIMEN_34.0PX</item> |
| 107 | </style> | 107 | </style> |
| 108 | + <style name="home_seek_bar" parent="@android:style/Widget.SeekBar"> | ||
| 109 | + <item name="android:maxHeight">1.5dip</item> | ||
| 110 | + <item name="android:progressDrawable">@drawable/home_sb_progress</item> | ||
| 111 | + <item name="android:minHeight">8.0dip</item> | ||
| 112 | + <item name="android:thumb">@drawable/home_thunmb</item> | ||
| 113 | + <item name="android:thumbOffset">10.0dip</item> | ||
| 114 | + </style> | ||
| 108 | </resources> | 115 | </resources> |
| @@ -52,9 +52,6 @@ import java.util.concurrent.atomic.AtomicInteger; | @@ -52,9 +52,6 @@ import java.util.concurrent.atomic.AtomicInteger; | ||
| 52 | import java.util.concurrent.atomic.AtomicLong; | 52 | import java.util.concurrent.atomic.AtomicLong; |
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | -/** | ||
| 56 | - * @author Michael Yang(www.yangfuhai.com) update at 2013.08.07 | ||
| 57 | - */ | ||
| 58 | public class ACache { | 55 | public class ACache { |
| 59 | public static final int TIME_HOUR = 60 * 60; | 56 | public static final int TIME_HOUR = 60 * 60; |
| 60 | public static final int TIME_DAY = TIME_HOUR * 24; | 57 | public static final int TIME_DAY = TIME_HOUR * 24; |
| @@ -176,7 +176,14 @@ public interface Constants { | @@ -176,7 +176,14 @@ public interface Constants { | ||
| 176 | String ERROR_XDYCORE_INIT="Uninitialized initialization, please init xysdk"; | 176 | String ERROR_XDYCORE_INIT="Uninitialized initialization, please init xysdk"; |
| 177 | /*判断输入的类型是否为空*/ | 177 | /*判断输入的类型是否为空*/ |
| 178 | String ERROR_TYPE_NULL="输入的type不能为空"; | 178 | String ERROR_TYPE_NULL="输入的type不能为空"; |
| 179 | - | 179 | + /** |
| 180 | + * surfaceview 为null | ||
| 181 | + */ | ||
| 182 | + String ERROR_TYPE_SURFACEVIEW="xdysdk surfaceview is null"; | ||
| 183 | + /** | ||
| 184 | + * activity is null | ||
| 185 | + */ | ||
| 186 | + String ERROR_TYPE_ACTIVITY="xdysdk activity is null"; | ||
| 180 | 187 | ||
| 181 | /**********************************以下实现为自定义code 先定义后实现*********************************************************************/ | 188 | /**********************************以下实现为自定义code 先定义后实现*********************************************************************/ |
| 182 | /** | 189 | /** |
| @@ -24,6 +24,8 @@ public class XdyJsCore { | @@ -24,6 +24,8 @@ public class XdyJsCore { | ||
| 24 | private WebView mWebView; | 24 | private WebView mWebView; |
| 25 | private static String TAG="xdyjscore"; | 25 | private static String TAG="xdyjscore"; |
| 26 | private static XdyJsCore mXdyCore; | 26 | private static XdyJsCore mXdyCore; |
| 27 | + protected boolean isDestroy=false; | ||
| 28 | + private XdyJavaScript mXdyJavaScript; | ||
| 27 | /** | 29 | /** |
| 28 | * 异步对外回调接口,所有回调都在此完成 | 30 | * 异步对外回调接口,所有回调都在此完成 |
| 29 | */ | 31 | */ |
| @@ -50,16 +52,21 @@ public class XdyJsCore { | @@ -50,16 +52,21 @@ public class XdyJsCore { | ||
| 50 | * @param context | 52 | * @param context |
| 51 | */ | 53 | */ |
| 52 | protected void init(Context context){ | 54 | protected void init(Context context){ |
| 55 | + //清理Webview缓存数据库 | ||
| 56 | + | ||
| 53 | mWebView=new WebView(context); | 57 | mWebView=new WebView(context); |
| 54 | WebSettings webSettings=mWebView.getSettings(); | 58 | WebSettings webSettings=mWebView.getSettings(); |
| 55 | webSettings.setJavaScriptEnabled(true); | 59 | webSettings.setJavaScriptEnabled(true); |
| 56 | - mWebView.addJavascriptInterface(new XdyJavaScript(), APIContants.NATIVE_JS_LINK); | 60 | + mWebView.getSettings().setAppCacheEnabled(false); |
| 61 | + webSettings. setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存 | ||
| 62 | + mXdyJavaScript=new XdyJavaScript(); | ||
| 63 | + mWebView.addJavascriptInterface(mXdyJavaScript, APIContants.NATIVE_JS_LINK); | ||
| 57 | mWebView.setWebChromeClient(new WebChromeClient(){ | 64 | mWebView.setWebChromeClient(new WebChromeClient(){ |
| 58 | @Override | 65 | @Override |
| 59 | public void onConsoleMessage(String message, int lineNumber, String sourceID) { | 66 | public void onConsoleMessage(String message, int lineNumber, String sourceID) { |
| 60 | super.onConsoleMessage(message, lineNumber, sourceID); | 67 | super.onConsoleMessage(message, lineNumber, sourceID); |
| 61 | //TODO 发布时去掉 | 68 | //TODO 发布时去掉 |
| 62 | -// XdyLogUtil.e("message:"+message+" lineNumber:"+" sourceId:"+sourceID); | 69 | + XdyLogUtil.e("message:"+message+" lineNumber:"+" sourceId:"+sourceID); |
| 63 | } | 70 | } |
| 64 | }); | 71 | }); |
| 65 | mWebView.post(new Runnable() { | 72 | mWebView.post(new Runnable() { |
| @@ -96,8 +103,7 @@ public class XdyJsCore { | @@ -96,8 +103,7 @@ public class XdyJsCore { | ||
| 96 | if(mOnXdyAsyncMessageListener !=null){ | 103 | if(mOnXdyAsyncMessageListener !=null){ |
| 97 | mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,parmp); | 104 | mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,parmp); |
| 98 | } | 105 | } |
| 99 | - //TODo 使用观察者传递数 | ||
| 100 | - XdySdk.getXdyInstance().notifyObserver(id,parmp); | 106 | + XdySdk.getXdyInstance().notifyObserver(id, parmp); |
| 101 | } | 107 | } |
| 102 | } | 108 | } |
| 103 | 109 | ||
| @@ -106,11 +112,9 @@ public class XdyJsCore { | @@ -106,11 +112,9 @@ public class XdyJsCore { | ||
| 106 | * @param id | 112 | * @param id |
| 107 | * @param parameter | 113 | * @param parameter |
| 108 | */ | 114 | */ |
| 109 | - protected void native2js(final String id, final String parameter) { | 115 | + protected void native2js( String id, String parameter) { |
| 110 | XdyLogUtil.e("推流线程native2js:",Thread.currentThread().getId()+""); | 116 | XdyLogUtil.e("推流线程native2js:",Thread.currentThread().getId()+""); |
| 111 | -// mWebView.post(new Runnable() { | ||
| 112 | -// @Override | ||
| 113 | -// public void run() { | 117 | + |
| 114 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | 118 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| 115 | mWebView.evaluateJavascript("javascript:_native2js('" + id + "','"+parameter+"')", new ValueCallback<String>() { | 119 | mWebView.evaluateJavascript("javascript:_native2js('" + id + "','"+parameter+"')", new ValueCallback<String>() { |
| 116 | @Override | 120 | @Override |
| @@ -122,11 +126,11 @@ public class XdyJsCore { | @@ -122,11 +126,11 @@ public class XdyJsCore { | ||
| 122 | // mOnXdyAsyncMessageListener.getSdyAsyncMessageListener("live",value); | 126 | // mOnXdyAsyncMessageListener.getSdyAsyncMessageListener("live",value); |
| 123 | // } | 127 | // } |
| 124 | // } | 128 | // } |
| 125 | - if (!TextUtils.isEmpty(value)&&value.length()>10) { | ||
| 126 | - if(mOnXdyAsyncMessageListener !=null){ | ||
| 127 | - mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,value); | ||
| 128 | - } | ||
| 129 | - } | 129 | +// if (!TextUtils.isEmpty(value)&&value.length()>10) { |
| 130 | +// if(mOnXdyAsyncMessageListener !=null){ | ||
| 131 | +// mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,value); | ||
| 132 | +// } | ||
| 133 | +// } | ||
| 130 | } | 134 | } |
| 131 | }); | 135 | }); |
| 132 | }else{ | 136 | }else{ |
| @@ -134,6 +138,17 @@ public class XdyJsCore { | @@ -134,6 +138,17 @@ public class XdyJsCore { | ||
| 134 | } | 138 | } |
| 135 | 139 | ||
| 136 | } | 140 | } |
| 137 | -// }); | ||
| 138 | -// } | 141 | + |
| 142 | + /** | ||
| 143 | + * 清除缓存 | ||
| 144 | + */ | ||
| 145 | + public void onDestroy(){ | ||
| 146 | + if(mWebView!=null){ | ||
| 147 | + mWebView.clearHistory(); | ||
| 148 | + } | ||
| 149 | + if(mXdyJavaScript!=null){ | ||
| 150 | + mXdyJavaScript=null; | ||
| 151 | + } | ||
| 152 | + mXdyJavaScript= new XdyJavaScript(); | ||
| 153 | + } | ||
| 139 | } | 154 | } |
| @@ -48,7 +48,7 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC | @@ -48,7 +48,7 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC | ||
| 48 | private int videoHight = 480; | 48 | private int videoHight = 480; |
| 49 | private boolean isStart = false; | 49 | private boolean isStart = false; |
| 50 | /*是否支持硬编码 默认不支持*/ | 50 | /*是否支持硬编码 默认不支持*/ |
| 51 | - private boolean is_hardware_encoder = true; | 51 | + private boolean is_hardware_encoder = false; |
| 52 | 52 | ||
| 53 | static { | 53 | static { |
| 54 | System.loadLibrary("SmartPublisher"); | 54 | System.loadLibrary("SmartPublisher"); |
| @@ -59,6 +59,7 @@ public class XdySdk implements SubjectListener{ | @@ -59,6 +59,7 @@ public class XdySdk implements SubjectListener{ | ||
| 59 | private Activity mActivity; | 59 | private Activity mActivity; |
| 60 | /*是否正在推流,mcu自动断开的时候使用,推流成功后才表示正在使用*/ | 60 | /*是否正在推流,mcu自动断开的时候使用,推流成功后才表示正在使用*/ |
| 61 | private boolean isPublisher=false; | 61 | private boolean isPublisher=false; |
| 62 | + /*观察者集合*/ | ||
| 62 | private List<ObserverListener> observerListenerList=new ArrayList<ObserverListener>(); | 63 | private List<ObserverListener> observerListenerList=new ArrayList<ObserverListener>(); |
| 63 | 64 | ||
| 64 | @Override | 65 | @Override |
| @@ -71,8 +72,6 @@ public class XdySdk implements SubjectListener{ | @@ -71,8 +72,6 @@ public class XdySdk implements SubjectListener{ | ||
| 71 | handleData(type,parameter); | 72 | handleData(type,parameter); |
| 72 | XdyLogUtil.e("notifyObserVer","type:"+type+" parameter:"+parameter); | 73 | XdyLogUtil.e("notifyObserVer","type:"+type+" parameter:"+parameter); |
| 73 | 74 | ||
| 74 | - | ||
| 75 | - | ||
| 76 | } | 75 | } |
| 77 | 76 | ||
| 78 | @Override | 77 | @Override |
| @@ -83,6 +82,16 @@ public class XdySdk implements SubjectListener{ | @@ -83,6 +82,16 @@ public class XdySdk implements SubjectListener{ | ||
| 83 | } | 82 | } |
| 84 | 83 | ||
| 85 | /** | 84 | /** |
| 85 | + * 清除信息 | ||
| 86 | + */ | ||
| 87 | + public void removeAll(){ | ||
| 88 | +// if(observerListenerList!=null){ | ||
| 89 | +// observerListenerList.clear(); | ||
| 90 | +// } | ||
| 91 | + mXdyJsCore.onDestroy(); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 86 | * 对外提供的异步消息接收接口) | 95 | * 对外提供的异步消息接收接口) |
| 87 | */ | 96 | */ |
| 88 | public interface OnXdyAsyncMessageLitener{ | 97 | public interface OnXdyAsyncMessageLitener{ |
| @@ -99,7 +108,7 @@ public class XdySdk implements SubjectListener{ | @@ -99,7 +108,7 @@ public class XdySdk implements SubjectListener{ | ||
| 99 | * 设置监听 | 108 | * 设置监听 |
| 100 | */ | 109 | */ |
| 101 | public void setOnXdyAsyncMessageLitener(OnXdyAsyncMessageLitener onXdyAsyncMessageLitener){ | 110 | public void setOnXdyAsyncMessageLitener(OnXdyAsyncMessageLitener onXdyAsyncMessageLitener){ |
| 102 | - judgeCore();; | 111 | + judgeCore(); |
| 103 | mOnXdyAsyncMessageLitener=onXdyAsyncMessageLitener; | 112 | mOnXdyAsyncMessageLitener=onXdyAsyncMessageLitener; |
| 104 | } | 113 | } |
| 105 | private XdySdk(){} | 114 | private XdySdk(){} |
| @@ -119,7 +128,7 @@ public class XdySdk implements SubjectListener{ | @@ -119,7 +128,7 @@ public class XdySdk implements SubjectListener{ | ||
| 119 | throw new IllegalArgumentException(Constants.ERROR_CONTENT_NULL); | 128 | throw new IllegalArgumentException(Constants.ERROR_CONTENT_NULL); |
| 120 | } | 129 | } |
| 121 | aCache=ACache.get(context); | 130 | aCache=ACache.get(context); |
| 122 | - mContext=context; | 131 | + mContext=context; |
| 123 | mXdyJsCore = XdyJsCore.getInstance(context); | 132 | mXdyJsCore = XdyJsCore.getInstance(context); |
| 124 | mMsgManage=MsgManage.getErrorMsgInstance(); | 133 | mMsgManage=MsgManage.getErrorMsgInstance(); |
| 125 | // mMsgManage.setXdyMsgManageListener(new MsgManage.OnXdyMsgManageListener() { | 134 | // mMsgManage.setXdyMsgManageListener(new MsgManage.OnXdyMsgManageListener() { |
| @@ -142,6 +151,7 @@ public class XdySdk implements SubjectListener{ | @@ -142,6 +151,7 @@ public class XdySdk implements SubjectListener{ | ||
| 142 | // @Override | 151 | // @Override |
| 143 | // public void run() { | 152 | // public void run() { |
| 144 | // handleData(id,parameter); | 153 | // handleData(id,parameter); |
| 154 | +// | ||
| 145 | // } | 155 | // } |
| 146 | // }); | 156 | // }); |
| 147 | // | 157 | // |
| @@ -171,6 +181,9 @@ public class XdySdk implements SubjectListener{ | @@ -171,6 +181,9 @@ public class XdySdk implements SubjectListener{ | ||
| 171 | //停止播放video( 停止播放:根据api) | 181 | //停止播放video( 停止播放:根据api) |
| 172 | // onPlayStop(); | 182 | // onPlayStop(); |
| 173 | break; | 183 | break; |
| 184 | + case "init": | ||
| 185 | + mXdyJsCore.isDestroy=false; | ||
| 186 | + break; | ||
| 174 | } | 187 | } |
| 175 | handler.post(new Runnable() { | 188 | handler.post(new Runnable() { |
| 176 | @Override | 189 | @Override |
| @@ -256,7 +269,7 @@ public class XdySdk implements SubjectListener{ | @@ -256,7 +269,7 @@ public class XdySdk implements SubjectListener{ | ||
| 256 | case Constants.PUBLISH_AUDIO: | 269 | case Constants.PUBLISH_AUDIO: |
| 257 | //只推送音频 | 270 | //只推送音频 |
| 258 | getPublishPathAudio(); | 271 | getPublishPathAudio(); |
| 259 | - mSurfaceView=surfaceView; | 272 | +// mSurfaceView=surfaceView; |
| 260 | mActivity=activity; | 273 | mActivity=activity; |
| 261 | break; | 274 | break; |
| 262 | 275 | ||
| @@ -322,17 +335,17 @@ public class XdySdk implements SubjectListener{ | @@ -322,17 +335,17 @@ public class XdySdk implements SubjectListener{ | ||
| 322 | if(getPublishPathReceiveBean!=null) { | 335 | if(getPublishPathReceiveBean!=null) { |
| 323 | //可以推流了 | 336 | //可以推流了 |
| 324 | if (getPublishPathReceiveBean.getCode() == 0) { | 337 | if (getPublishPathReceiveBean.getCode() == 0) { |
| 325 | - //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字 | 338 | + //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用video_get_publish_path关键字 只支持做只支一路 |
| 326 | String video_url = getPublishPathReceiveBean.getPublishUrl(); | 339 | String video_url = getPublishPathReceiveBean.getPublishUrl(); |
| 327 | aCache.put(Constants.VIDEO_GET_PUBLISH_PATH, video_url); | 340 | aCache.put(Constants.VIDEO_GET_PUBLISH_PATH, video_url); |
| 328 | //判断 | 341 | //判断 |
| 329 | if (mSurfaceView == null) { | 342 | if (mSurfaceView == null) { |
| 330 | //todo 输出提示 | 343 | //todo 输出提示 |
| 331 | - return; | 344 | + throw new IllegalArgumentException(Constants.ERROR_TYPE_SURFACEVIEW); |
| 332 | } | 345 | } |
| 333 | if (mActivity == null) { | 346 | if (mActivity == null) { |
| 334 | //TODo 给出提示 | 347 | //TODo 给出提示 |
| 335 | - return; | 348 | + throw new IllegalArgumentException(Constants.ERROR_TYPE_ACTIVITY); |
| 336 | } | 349 | } |
| 337 | if (mXdyPublisherCore == null) { | 350 | if (mXdyPublisherCore == null) { |
| 338 | mXdyPublisherCore = new XdyPublisherCore(1, 1, mActivity); | 351 | mXdyPublisherCore = new XdyPublisherCore(1, 1, mActivity); |
| @@ -360,11 +373,11 @@ public class XdySdk implements SubjectListener{ | @@ -360,11 +373,11 @@ public class XdySdk implements SubjectListener{ | ||
| 360 | //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字 | 373 | //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字 |
| 361 | aCache.put(Constants.GET_VIDEO_PUBLISH_PATH,audio_url); | 374 | aCache.put(Constants.GET_VIDEO_PUBLISH_PATH,audio_url); |
| 362 | //判断 | 375 | //判断 |
| 363 | - if (mSurfaceView==null){ | ||
| 364 | - //todo 输出提示 | ||
| 365 | - XdyLogUtil.e(TAG,"surfaceView is null"); | ||
| 366 | - return; | ||
| 367 | - } | 376 | +// if (mSurfaceView==null){ |
| 377 | +// //todo 输出提示 | ||
| 378 | +// XdyLogUtil.e(TAG,"surfaceView is null"); | ||
| 379 | +// return; | ||
| 380 | +// } | ||
| 368 | if(mActivity==null){ | 381 | if(mActivity==null){ |
| 369 | //TODo 给出提示 | 382 | //TODo 给出提示 |
| 370 | XdyLogUtil.e(TAG,"activity is null"); | 383 | XdyLogUtil.e(TAG,"activity is null"); |
| @@ -540,11 +553,12 @@ public class XdySdk implements SubjectListener{ | @@ -540,11 +553,12 @@ public class XdySdk implements SubjectListener{ | ||
| 540 | break; | 553 | break; |
| 541 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP: | 554 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP: |
| 542 | Log.i(TAG, "关闭。。"); | 555 | Log.i(TAG, "关闭。。"); |
| 543 | - XdySdk.getXdyInstance().notifyObserver("play_stop",currentPlayId+""); | 556 | + notifyObserver("play_stop",currentPlayId+""); |
| 544 | break; | 557 | break; |
| 545 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO: | 558 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO: |
| 546 | Log.i(TAG, "分辨率信息: width: " + param1 + ", height: " + param2); | 559 | Log.i(TAG, "分辨率信息: width: " + param1 + ", height: " + param2); |
| 547 | - XdySdk.getXdyInstance().notifyObserver("video_success",currentPlayId+""); | 560 | + //在这里最接近得到播放的成功的准确回调 |
| 561 | + notifyObserver("video_success",currentPlayId+""); | ||
| 548 | break; | 562 | break; |
| 549 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED: | 563 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED: |
| 550 | Log.i(TAG, "收不到媒体数据,可能是url错误。。"); | 564 | Log.i(TAG, "收不到媒体数据,可能是url错误。。"); |
| @@ -6,7 +6,7 @@ package com.mang.xdy.listener; | @@ -6,7 +6,7 @@ package com.mang.xdy.listener; | ||
| 6 | 6 | ||
| 7 | public interface ObserverListener { | 7 | public interface ObserverListener { |
| 8 | /** | 8 | /** |
| 9 | - * | 9 | + *更新数据 |
| 10 | * @param type 类型 | 10 | * @param type 类型 |
| 11 | * @param parameter 参数 | 11 | * @param parameter 参数 |
| 12 | */ | 12 | */ |
| @@ -5,7 +5,21 @@ package com.mang.xdy.listener; | @@ -5,7 +5,21 @@ package com.mang.xdy.listener; | ||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | public interface SubjectListener { | 7 | public interface SubjectListener { |
| 8 | + /** | ||
| 9 | + * 添加监听 | ||
| 10 | + * @param observerListener | ||
| 11 | + */ | ||
| 8 | void add(ObserverListener observerListener); | 12 | void add(ObserverListener observerListener); |
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 更新数据 | ||
| 16 | + * @param type | ||
| 17 | + * @param parameter | ||
| 18 | + */ | ||
| 9 | void notifyObserver(String type,String parameter); | 19 | void notifyObserver(String type,String parameter); |
| 20 | + /** | ||
| 21 | + * 移除监听 | ||
| 22 | + * @param observerListener | ||
| 23 | + */ | ||
| 10 | void remove(ObserverListener observerListener); | 24 | void remove(ObserverListener observerListener); |
| 11 | } | 25 | } |
-
请 注册 或 登录 后发表评论