huangxinbao

add chat

正在显示 26 个修改的文件 包含 725 行增加166 行删除
@@ -32,24 +32,25 @@ dependencies { @@ -32,24 +32,25 @@ dependencies {
32 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 32 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
33 exclude group: 'com.android.support', module: 'support-annotations' 33 exclude group: 'com.android.support', module: 'support-annotations'
34 }) 34 })
  35 + compile project(':xdy')
  36 +
  37 +
  38 +
  39 + compile files('libs/pldroid-player-1.5.1.jar')
35 compile 'com.android.support:appcompat-v7:25.3.1' 40 compile 'com.android.support:appcompat-v7:25.3.1'
36 - testCompile 'junit:junit:4.12'  
37 compile 'com.jakewharton:butterknife:8.5.1' 41 compile 'com.jakewharton:butterknife:8.5.1'
38 - annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'  
39 - compile 'com.android.support:design:23.4.0' 42 + compile 'com.android.support:design:25.3.1'
40 compile 'com.squareup.picasso:picasso:2.3.2' 43 compile 'com.squareup.picasso:picasso:2.3.2'
41 compile 'com.github.bumptech.glide:glide:3.7.0' 44 compile 'com.github.bumptech.glide:glide:3.7.0'
42 - compile project(':xdy')  
43 compile 'com.rockerhieu.emojicon:library:1.3.1' 45 compile 'com.rockerhieu.emojicon:library:1.3.1'
44 compile 'org.kymjs.kjframe:kjframe:2.6' 46 compile 'org.kymjs.kjframe:kjframe:2.6'
45 -  
46 compile 'io.reactivex:rxjava:1.0.9' 47 compile 'io.reactivex:rxjava:1.0.9'
47 compile 'io.reactivex:rxandroid:0.24.0' 48 compile 'io.reactivex:rxandroid:0.24.0'
48 compile 'com.squareup.retrofit:retrofit:1.9.0' 49 compile 'com.squareup.retrofit:retrofit:1.9.0'
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 compile 'com.qiniu:happy-dns:0.2.+'
  53 + compile 'com.android.support:support-v4:25.3.1'
  54 + testCompile 'junit:junit:4.12'
  55 + annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
55 } 56 }
@@ -26,11 +26,10 @@ @@ -26,11 +26,10 @@
26 <uses-permission android:name="android.permission.VIBRATE" /> 26 <uses-permission android:name="android.permission.VIBRATE" />
27 27
28 28
29 -  
30 <application 29 <application
31 android:name=".application.XdyApplicaiton" 30 android:name=".application.XdyApplicaiton"
32 android:allowBackup="true" 31 android:allowBackup="true"
33 - android:icon="@mipmap/ic_launcher" 32 + android:icon="@mipmap/logo"
34 android:label="@string/app_name" 33 android:label="@string/app_name"
35 android:supportsRtl="true" 34 android:supportsRtl="true"
36 android:theme="@style/AppTheme"> 35 android:theme="@style/AppTheme">
@@ -36,6 +36,7 @@ import com.mang.xdy.demo.bean.VideoOrAudioStopEntity; @@ -36,6 +36,7 @@ import com.mang.xdy.demo.bean.VideoOrAudioStopEntity;
36 import com.mang.xdy.demo.utils.JsonUtil; 36 import com.mang.xdy.demo.utils.JsonUtil;
37 import com.mang.xdy.demo.utils.ToastUtil; 37 import com.mang.xdy.demo.utils.ToastUtil;
38 import com.mang.xdy.demo.widget.dialog.LoginDialog; 38 import com.mang.xdy.demo.widget.dialog.LoginDialog;
  39 +import com.mang.xdy.demo.widget.view.NoScrollViewPager;
39 import com.mang.xdy.listener.ObserverListener; 40 import com.mang.xdy.listener.ObserverListener;
40 import com.mang.xdy.utils.UIUtils; 41 import com.mang.xdy.utils.UIUtils;
41 import com.mang.xdy.utils.XdyLogUtil; 42 import com.mang.xdy.utils.XdyLogUtil;
@@ -65,7 +66,8 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -65,7 +66,8 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
65 private String username = ""; 66 private String username = "";
66 private String userpwd = ""; 67 private String userpwd = "";
67 private SimpleFragmentPagerAdapter pagerAdapter; 68 private SimpleFragmentPagerAdapter pagerAdapter;
68 - private ViewPager viewPager; 69 + @BindView(R.id.viewpager)
  70 + NoScrollViewPager viewPager;
69 private TabLayout tabLayout; 71 private TabLayout tabLayout;
70 @BindView(R.id.surfaceview_playVideo) 72 @BindView(R.id.surfaceview_playVideo)
71 SurfaceView surfaceviewPlayVideo; 73 SurfaceView surfaceviewPlayVideo;
@@ -75,6 +77,12 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -75,6 +77,12 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
75 private ProgressDialog mProgressDialog; 77 private ProgressDialog mProgressDialog;
76 @BindView(R.id.img_playVideo_replay) 78 @BindView(R.id.img_playVideo_replay)
77 PLVideoTextureView mVideoView; 79 PLVideoTextureView mVideoView;
  80 + private String playVideoOrAudioId="";
  81 + //视频模式还是音频模式
  82 + private boolean isVideoMode=true;
  83 + /*mcu断开或者网络原因为false*/
  84 + private boolean isDefaultExit=true;
  85 + private AlertDialog mErrorDialog;
78 //TODO 默认回放 86 //TODO 默认回放
79 private boolean replay = true; 87 private boolean replay = true;
80 private Handler mmHandler = new Handler() { 88 private Handler mmHandler = new Handler() {
@@ -83,28 +91,39 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -83,28 +91,39 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
83 super.handleMessage(msg); 91 super.handleMessage(msg);
84 ResponseEntity responseEntity = (ResponseEntity) msg.obj; 92 ResponseEntity responseEntity = (ResponseEntity) msg.obj;
85 switch (responseEntity.getType()) { 93 switch (responseEntity.getType()) {
  94 +
  95 + case Constants.CLASS_EXIT:
  96 + xdySdk.removeAll();
  97 + ToastUtil.showToast("退出课堂",VideoPlayActivity.this);
  98 + progressDialogDismiss();
  99 + exit();
  100 + break;
86 case Constants.ERROR_CODE: 101 case Constants.ERROR_CODE:
87 handError(responseEntity.getType(), responseEntity.getParam()); 102 handError(responseEntity.getType(), responseEntity.getParam());
88 break; 103 break;
89 case Constants.CLASS_INIT_SUCCESS: 104 case Constants.CLASS_INIT_SUCCESS:
90 String login = responseEntity.getParam(); 105 String login = responseEntity.getParam();
91 parseJoinClass(login, true); 106 parseJoinClass(login, true);
92 - ToastUtil.showToastshort("初始化课堂成功", VideoPlayActivity.this); 107 +// ToastUtil.showToastshort("初始化课堂成功", VideoPlayActivity.this);
93 break; 108 break;
94 case Constants.CLASS_JOIN_SUCCESS: 109 case Constants.CLASS_JOIN_SUCCESS:
95 //加入课堂成功 110 //加入课堂成功
96 progressDialogDismiss(); 111 progressDialogDismiss();
97 UIUtils.closeDialog(mLoginDialog); 112 UIUtils.closeDialog(mLoginDialog);
98 - ToastUtil.showToastshort("加入课堂成功", VideoPlayActivity.this); 113 +// ToastUtil.showToastshort("加入课堂成功", VideoPlayActivity.this);
99 String userJson = responseEntity.getParam(); 114 String userJson = responseEntity.getParam();
100 SPUtil.putString(VideoPlayActivity.this, Constants.CLASS_JOIN_SUCCESS, userJson); 115 SPUtil.putString(VideoPlayActivity.this, Constants.CLASS_JOIN_SUCCESS, userJson);
101 break; 116 break;
102 case Constants.VIDEO_PLAY: 117 case Constants.VIDEO_PLAY:
103 //播放视频 118 //播放视频
  119 + playVideoOrAudioId=responseEntity.getParam();
  120 + isVideoMode=true;
104 playVideo(responseEntity.getParam()); 121 playVideo(responseEntity.getParam());
105 break; 122 break;
106 case Constants.AUDIO_PLAY: 123 case Constants.AUDIO_PLAY:
107 //播放音频 124 //播放音频
  125 + isVideoMode=false;
  126 + playVideoOrAudioId=responseEntity.getParam();
108 playAudio(responseEntity.getParam()); 127 playAudio(responseEntity.getParam());
109 break; 128 break;
110 case Constants.VIDEO_STOP: 129 case Constants.VIDEO_STOP:
@@ -113,11 +132,12 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -113,11 +132,12 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
113 //停止播放 132 //停止播放
114 stopPlay(responseEntity.getParam()); 133 stopPlay(responseEntity.getParam());
115 break; 134 break;
116 - case "video_success": 135 + case Constants.PLAY_SUCCESS:
117 //自定义消息 播放视频音频都通过这个来判断 136 //自定义消息 播放视频音频都通过这个来判断
118 img_playVideo_novideo.setVisibility(View.GONE); 137 img_playVideo_novideo.setVisibility(View.GONE);
119 break; 138 break;
120 139
  140 +
121 } 141 }
122 } 142 }
123 }; 143 };
@@ -128,7 +148,7 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -128,7 +148,7 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
128 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //屏幕常亮 148 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //屏幕常亮
129 setContentView(R.layout.activity_video_play); 149 setContentView(R.layout.activity_video_play);
130 ButterKnife.bind(this); 150 ButterKnife.bind(this);
131 - XdySdk.init(this); 151 +// XdySdk.init(this);
132 xdySdk = XdySdk.getXdyInstance(); 152 xdySdk = XdySdk.getXdyInstance();
133 xdySdk.add(this); 153 xdySdk.add(this);
134 init(); 154 init();
@@ -142,30 +162,30 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -142,30 +162,30 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
142 btn_videoPlay_exit.setOnClickListener(new View.OnClickListener() { 162 btn_videoPlay_exit.setOnClickListener(new View.OnClickListener() {
143 @Override 163 @Override
144 public void onClick(View v) { 164 public void onClick(View v) {
145 -// xdySdk.api("leaveClass", ""); 165 + xdySdk.api("leaveClass", "");
146 166
147 // 167 //
148 // xdySdk.remove(VideoPlayActivity.this); 168 // xdySdk.remove(VideoPlayActivity.this);
149 // xdySdk.removeAll(); 169 // xdySdk.removeAll();
150 // UIUtils.closeDialog(mLoginDialog); 170 // UIUtils.closeDialog(mLoginDialog);
151 // VideoPlayActivity.super.onBackPressed(); 171 // 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); 172 +// exit();
  173 +// String id="initRecordPlayback";
  174 +// String param="{\n" +
  175 +// " \"classId\": 479270427 ,\n" +
  176 +// " \"portal\": \"112.126.80.182:90\",\n" +
  177 +// " \"userRole\": \"normal\",\n" +
  178 +// " \"userName\": \"\",\n" +
  179 +// " \"userId\": 0\n" +
  180 +// "}";
  181 +// String ss=XdyStringUtils.stringToJson(param,true);
  182 +// xdySdk.api(id,ss);
  183 +// mHandler.postDelayed(new Runnable() {
  184 +// @Override
  185 +// public void run() {
  186 +// xdySdk.api("startRecordPlayback", "");
  187 +// }
  188 +// }, 200);
169 189
170 } 190 }
171 }); 191 });
@@ -173,10 +193,10 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -173,10 +193,10 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
173 193
174 public void setTablayout() { 194 public void setTablayout() {
175 pagerAdapter = new SimpleFragmentPagerAdapter(getSupportFragmentManager(), this); 195 pagerAdapter = new SimpleFragmentPagerAdapter(getSupportFragmentManager(), this);
176 - viewPager = (ViewPager) findViewById(R.id.viewpager);  
177 viewPager.setAdapter(pagerAdapter); 196 viewPager.setAdapter(pagerAdapter);
178 tabLayout = (TabLayout) findViewById(R.id.sliding_tabs); 197 tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
179 - tabLayout.setupWithViewPager(viewPager); 198 +// tabLayout.setupWithViewPager(viewPager);
  199 + tabLayout.setupWithViewPager(viewPager,false);
180 tabLayout.setTabMode(TabLayout.MODE_FIXED); 200 tabLayout.setTabMode(TabLayout.MODE_FIXED);
181 } 201 }
182 202
@@ -282,15 +302,12 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -282,15 +302,12 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
282 .setPositiveButton("确认", new DialogInterface.OnClickListener() { 302 .setPositiveButton("确认", new DialogInterface.OnClickListener() {
283 @Override 303 @Override
284 public void onClick(DialogInterface dialogInterface, int i) { 304 public void onClick(DialogInterface dialogInterface, int i) {
285 - xdySdk.onPlayDestroy(); 305 +
286 xdySdk.api("leaveClass", ""); 306 xdySdk.api("leaveClass", "");
287 -//  
288 -// xdySdk.remove(VideoPlayActivity.this);  
289 - xdySdk.removeAll(); 307 + //如果收到class_exit 就执行,退出界面
290 UIUtils.closeDialog(mLoginDialog); 308 UIUtils.closeDialog(mLoginDialog);
291 -// VideoPlayActivity.super.onBackPressed();  
292 - Exit();  
293 - 309 + exit();
  310 +// progressDialogShow();
294 } 311 }
295 }) 312 })
296 .create(); 313 .create();
@@ -329,7 +346,7 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -329,7 +346,7 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
329 case "207": 346 case "207":
330 case "208": 347 case "208":
331 ToastUtil.showToastshort(errorEntity.getReson(), this); 348 ToastUtil.showToastshort(errorEntity.getReson(), this);
332 - Exit(); 349 + exit();
333 break; 350 break;
334 case "300": 351 case "300":
335 case "301": 352 case "301":
@@ -342,20 +359,39 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -342,20 +359,39 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
342 ToastUtil.showToastshort(errorEntity.getReson(), this); 359 ToastUtil.showToastshort(errorEntity.getReson(), this);
343 break; 360 break;
344 case "20000": 361 case "20000":
345 - ToastUtil.showToastshort(errorEntity.getReson(), this); 362 + isDefaultExit=false;
  363 + showErrorDialog();
  364 +// ToastUtil.showToastshort(errorEntity.getReson(), this);
346 break; 365 break;
347 } 366 }
348 367
349 368
350 } 369 }
351 370
  371 + @Override
  372 + protected void onPause() {
  373 + super.onPause();
  374 + xdySdk.onPlayStop(playVideoOrAudioId);
  375 + }
  376 +
  377 + @Override
  378 + protected void onResume() {
  379 + super.onResume();
  380 + if(isVideoMode) {
  381 + playVideo(playVideoOrAudioId);
  382 + }else{
  383 + playAudio(playVideoOrAudioId);
  384 + }
  385 + }
  386 +
352 /** 387 /**
353 * 错误情况退出 388 * 错误情况退出
354 */ 389 */
355 - public void Exit() { 390 + public void exit() {
356 xdySdk.remove(this); 391 xdySdk.remove(this);
357 UIUtils.closeDialog(mLoginDialog); 392 UIUtils.closeDialog(mLoginDialog);
358 -// mmHandler.removeCallbacksAndMessages(null); 393 + xdySdk.onPlayPauseAll();
  394 + mmHandler.removeCallbacksAndMessages(null);
359 this.finish(); 395 this.finish();
360 } 396 }
361 397
@@ -387,10 +423,32 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -387,10 +423,32 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
387 } 423 }
388 } 424 }
389 } 425 }
  426 + public void showErrorDialog() {
  427 + if(isDefaultExit){
  428 + return;
  429 + }
  430 + if (mErrorDialog != null)
  431 + return;
  432 +
  433 + mErrorDialog = new AlertDialog.Builder(this)
  434 + .setTitle("退出")
  435 + .setMessage("您设备的网络属于断开状态,请重新进入")
  436 + .setPositiveButton("确认", new DialogInterface.OnClickListener() {
  437 + @Override
  438 + public void onClick(DialogInterface dialogInterface, int i) {
  439 + dialogInterface.dismiss();
  440 + exit();
  441 + }
  442 + })
  443 + .create();
  444 + mErrorDialog.setCanceledOnTouchOutside(false);
  445 +
  446 + mErrorDialog.show();
390 447
  448 + }
391 @Override 449 @Override
392 public void observerUpData(String type, String parameter) { 450 public void observerUpData(String type, String parameter) {
393 - XdyLogUtil.e(TAG + "observer:", Thread.currentThread().getId() + ""); 451 + XdyLogUtil.e(TAG + "observer:", Thread.currentThread().getId() + "type:"+type);
394 ResponseEntity responseEntity = new ResponseEntity(type, parameter); 452 ResponseEntity responseEntity = new ResponseEntity(type, parameter);
395 Message message = Message.obtain(); 453 Message message = Message.obtain();
396 message.obj = responseEntity; 454 message.obj = responseEntity;
@@ -412,7 +470,7 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList @@ -412,7 +470,7 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
412 private RelativeLayout mPauseContainer; 470 private RelativeLayout mPauseContainer;
413 private TextView mClassName; 471 private TextView mClassName;
414 private SurfaceView mSurfaceView = null; 472 private SurfaceView mSurfaceView = null;
415 - private AlertDialog mErrorDialog; 473 +
416 @SuppressLint("HandlerLeak") 474 @SuppressLint("HandlerLeak")
417 private Handler mHandler = new Handler() { 475 private Handler mHandler = new Handler() {
418 @Override 476 @Override
@@ -33,6 +33,7 @@ package com.mang.xdy.demo.activity; @@ -33,6 +33,7 @@ package com.mang.xdy.demo.activity;
33 import com.mang.xdy.demo.bean.AudioPlayBean; 33 import com.mang.xdy.demo.bean.AudioPlayBean;
34 import com.mang.xdy.demo.bean.ChatBean; 34 import com.mang.xdy.demo.bean.ChatBean;
35 import com.mang.xdy.demo.bean.DocEntity; 35 import com.mang.xdy.demo.bean.DocEntity;
  36 + import com.mang.xdy.demo.bean.ErrorEntity;
36 import com.mang.xdy.demo.bean.InitClassSuccessEntity; 37 import com.mang.xdy.demo.bean.InitClassSuccessEntity;
37 import com.mang.xdy.demo.bean.JoinClass; 38 import com.mang.xdy.demo.bean.JoinClass;
38 import com.mang.xdy.demo.bean.LiveBean; 39 import com.mang.xdy.demo.bean.LiveBean;
@@ -43,6 +44,7 @@ package com.mang.xdy.demo.activity; @@ -43,6 +44,7 @@ package com.mang.xdy.demo.activity;
43 import com.mang.xdy.demo.utils.JsonUtil; 44 import com.mang.xdy.demo.utils.JsonUtil;
44 import com.mang.xdy.demo.utils.ToastUtil; 45 import com.mang.xdy.demo.utils.ToastUtil;
45 import com.mang.xdy.demo.widget.dialog.LoginDialog; 46 import com.mang.xdy.demo.widget.dialog.LoginDialog;
  47 + import com.mang.xdy.listener.ObserverListener;
46 import com.mang.xdy.utils.UIUtils; 48 import com.mang.xdy.utils.UIUtils;
47 import com.mang.xdy.utils.XdyLogUtil; 49 import com.mang.xdy.utils.XdyLogUtil;
48 import com.mang.xdy.utils.XdyStringUtils; 50 import com.mang.xdy.utils.XdyStringUtils;
@@ -51,7 +53,7 @@ package com.mang.xdy.demo.activity; @@ -51,7 +53,7 @@ package com.mang.xdy.demo.activity;
51 import butterknife.ButterKnife; 53 import butterknife.ButterKnife;
52 import butterknife.OnClick; 54 import butterknife.OnClick;
53 55
54 -public class VideoPublisherActivity extends AppCompatActivity { 56 +public class VideoPublisherActivity extends AppCompatActivity implements ObserverListener{
55 private final static String TAG = "VideoPlayActivity"; 57 private final static String TAG = "VideoPlayActivity";
56 @BindView(R.id.btn_videoPlay_pubsherVideo) 58 @BindView(R.id.btn_videoPlay_pubsherVideo)
57 Button btnVideoPlayPubsherVideo; 59 Button btnVideoPlayPubsherVideo;
@@ -120,6 +122,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -120,6 +122,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
120 btn_videoPlay_publisherAudio.setVisibility(View.GONE); 122 btn_videoPlay_publisherAudio.setVisibility(View.GONE);
121 // setTablayout(); 123 // setTablayout();
122 xdySdk=XdySdk.getXdyInstance(); 124 xdySdk=XdySdk.getXdyInstance();
  125 + xdySdk.add(this);
123 init(); 126 init();
124 XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+""); 127 XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+"");
125 xdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() { 128 xdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() {
@@ -248,8 +251,17 @@ private LoginDialog mLoginDialog; @@ -248,8 +251,17 @@ private LoginDialog mLoginDialog;
248 251
249 } 252 }
250 253
  254 + @Override
  255 + protected void onPause() {
  256 + super.onPause();
  257 + xdySdk.onPublisherPause();
  258 + }
251 259
252 - 260 + @Override
  261 + protected void onResume() {
  262 + super.onResume();
  263 + xdySdk.onPublisherResume();
  264 + }
253 265
254 @Override 266 @Override
255 protected void onDestroy() { 267 protected void onDestroy() {
@@ -278,6 +290,61 @@ private LoginDialog mLoginDialog; @@ -278,6 +290,61 @@ private LoginDialog mLoginDialog;
278 break; 290 break;
279 } 291 }
280 } 292 }
  293 +
  294 + @Override
  295 + public void observerUpData(final String type, final String parameter) {
  296 + handler.post(new Runnable() {
  297 + @Override
  298 + public void run() {
  299 + handError(type,parameter);
  300 + }
  301 + });
  302 + }
  303 + public void handError(String errorId, String errorMsg) {
  304 + ErrorEntity errorEntity = JsonUtil.parseJsonToBean(errorMsg, ErrorEntity.class);
  305 + if (errorEntity == null) {
  306 + return;
  307 + }
  308 + switch (errorEntity.getCode() + "") {
  309 + case "100":
  310 + case "101":
  311 + case "102":
  312 + case "103":
  313 + case "104":
  314 + case "105":
  315 + case "106":
  316 + case "107":
  317 + case "200":
  318 + case "201":
  319 + case "202":
  320 + case "203":
  321 + case "204":
  322 + case "205":
  323 + case "206":
  324 + case "207":
  325 + case "208":
  326 + ToastUtil.showToastshort(errorEntity.getReson(), this);
  327 + exit();
  328 + break;
  329 + case "300":
  330 + case "301":
  331 + break;
  332 + case "10000":
  333 + ToastUtil.showToastshort(errorEntity.getReson(), this);
  334 + break;
  335 + case "10001":
  336 + ToastUtil.showToastshort(errorEntity.getReson(), this);
  337 + break;
  338 + case "20000":
  339 + isDefaultExit=false;
  340 + showErrorDialog();
  341 + ToastUtil.showToastshort(errorEntity.getReson(), this);
  342 + break;
  343 + }
  344 +
  345 +
  346 + }
  347 +
281 class EventHande implements SmartEventCallback { 348 class EventHande implements SmartEventCallback {
282 @Override 349 @Override
283 public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) { 350 public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) {
@@ -315,8 +382,44 @@ private LoginDialog mLoginDialog; @@ -315,8 +382,44 @@ private LoginDialog mLoginDialog;
315 382
316 } 383 }
317 } 384 }
  385 + /*mcu断开或者网络原因为false*/
  386 + private boolean isDefaultExit=true;
  387 + private android.support.v7.app.AlertDialog mErrorDialog;
  388 + public void showErrorDialog() {
  389 +// if(isDefaultExit){
  390 +// return;
  391 +// }
  392 + if (mErrorDialog != null)
  393 + return;
318 394
  395 + mErrorDialog = new android.support.v7.app.AlertDialog.Builder(this)
  396 + .setTitle("退出")
  397 + .setMessage("您设备的网络属于断开状态,请重新进入")
  398 + .setPositiveButton("确认", new DialogInterface.OnClickListener() {
  399 + @Override
  400 + public void onClick(DialogInterface dialogInterface, int i) {
  401 + dialogInterface.dismiss();
  402 + exit();
  403 + }
  404 + })
  405 + .create();
  406 + mErrorDialog.setCanceledOnTouchOutside(false);
319 407
  408 + mErrorDialog.show();
  409 +
  410 + }
  411 +
  412 + /**
  413 + * 错误情况退出
  414 + */
  415 + public void exit() {
  416 +
  417 + UIUtils.closeDialog(mLoginDialog);
  418 +// xdySdk.onPublisherStop();
  419 + xdySdk.remove(this);
  420 + handler.removeCallbacksAndMessages(null);
  421 + this.finish();
  422 + }
320 class PersonDialog extends Dialog { 423 class PersonDialog extends Dialog {
321 public PersonDialog(Context context) { 424 public PersonDialog(Context context) {
322 this(context, false); 425 this(context, false);
@@ -276,13 +276,13 @@ public class DocFragment extends Fragment implements ObserverListener{ @@ -276,13 +276,13 @@ public class DocFragment extends Fragment implements ObserverListener{
276 @Override 276 @Override
277 public void onDestroyView() { 277 public void onDestroyView() {
278 super.onDestroyView(); 278 super.onDestroyView();
279 - xdySdk.remove(this);  
280 - if(mCanvasView!=null){  
281 - mCanvasView.clear();  
282 - }  
283 - if(bitmap!=null){  
284 - bitmap=null;  
285 - }  
286 - mHandler.removeCallbacksAndMessages(null); 279 +// xdySdk.remove(this);
  280 +// if(mCanvasView!=null){
  281 +// mCanvasView.clear();
  282 +// }
  283 +// if(bitmap!=null){
  284 +// bitmap=null;
  285 +// }
  286 +// mHandler.removeCallbacksAndMessages(null);
287 } 287 }
288 } 288 }
  1 +package com.mang.xdy.demo.fragment;
  2 +
  3 +
  4 +import android.os.Bundle;
  5 +import android.support.v4.app.Fragment;
  6 +import android.view.LayoutInflater;
  7 +import android.view.View;
  8 +import android.view.ViewGroup;
  9 +
  10 +import com.mang.xdy.demo.R;
  11 +
  12 +/**
  13 + * A simple {@link Fragment} subclass.
  14 + * Use the {@link PublishFragment#newInstance} factory method to
  15 + * create an instance of this fragment.
  16 + */
  17 +public class PublishFragment extends Fragment {
  18 + // TODO: Rename parameter arguments, choose names that match
  19 + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  20 + private static final String ARG_PARAM1 = "param1";
  21 + private static final String ARG_PARAM2 = "param2";
  22 +
  23 + // TODO: Rename and change types of parameters
  24 + private String mParam1;
  25 + private String mParam2;
  26 +
  27 +
  28 + public PublishFragment() {
  29 + // Required empty public constructor
  30 + }
  31 +
  32 + /**
  33 + * Use this factory method to create a new instance of
  34 + * this fragment using the provided parameters.
  35 + *
  36 + * @param param1 Parameter 1.
  37 + * @param param2 Parameter 2.
  38 + * @return A new instance of fragment PublishFragment.
  39 + */
  40 + // TODO: Rename and change types and number of parameters
  41 + public static PublishFragment newInstance(String param1, String param2) {
  42 + PublishFragment fragment = new PublishFragment();
  43 + Bundle args = new Bundle();
  44 + args.putString(ARG_PARAM1, param1);
  45 + args.putString(ARG_PARAM2, param2);
  46 + fragment.setArguments(args);
  47 + return fragment;
  48 + }
  49 +
  50 + @Override
  51 + public void onCreate(Bundle savedInstanceState) {
  52 + super.onCreate(savedInstanceState);
  53 + if (getArguments() != null) {
  54 + mParam1 = getArguments().getString(ARG_PARAM1);
  55 + mParam2 = getArguments().getString(ARG_PARAM2);
  56 + }
  57 + }
  58 +
  59 + @Override
  60 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
  61 + Bundle savedInstanceState) {
  62 + // Inflate the layout for this fragment
  63 + return inflater.inflate(R.layout.fragment_publish, container, false);
  64 + }
  65 +
  66 +}
  1 +package com.mang.xdy.demo.widget.view;
  2 +
  3 +import android.content.Context;
  4 +import android.support.v4.view.ViewPager;
  5 +import android.util.AttributeSet;
  6 +import android.view.MotionEvent;
  7 +
  8 +
  9 +/**
  10 + * Created by abao on 2017/4/26.
  11 + */
  12 +
  13 +public class NoScrollViewPager extends ViewPager {
  14 + private boolean isPagingEnabled = true;
  15 +
  16 + public NoScrollViewPager(Context context) {
  17 + super(context);
  18 + }
  19 +
  20 + public NoScrollViewPager(Context context, AttributeSet attrs) {
  21 + super(context, attrs);
  22 + }
  23 +
  24 + @Override
  25 + public boolean onTouchEvent(MotionEvent event) {
  26 + return this.isPagingEnabled && super.onTouchEvent(event);
  27 + }
  28 +
  29 + @Override
  30 + public boolean onInterceptTouchEvent(MotionEvent event) {
  31 +
  32 + return this.isPagingEnabled && super.onInterceptTouchEvent(event);
  33 + }
  34 +
  35 + public void setPagingEnabled(boolean b) {
  36 + this.isPagingEnabled = b;
  37 + }
  38 +
  39 + @Override
  40 + public boolean dispatchTouchEvent(MotionEvent ev) {
  41 + if (listener != null && ev.getAction() == MotionEvent.ACTION_DOWN) {
  42 + listener.onClick();
  43 + }
  44 + return super.dispatchTouchEvent(ev);
  45 + }
  46 +
  47 + private OnRplayTouchListener listener;
  48 +
  49 + public interface OnRplayTouchListener {
  50 + public void onClick();
  51 + }
  52 +
  53 + public void setOnRplayTouchListener(OnRplayTouchListener listener) {
  54 + this.listener = listener;
  55 + }
  56 +}
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 android:id="@+id/edt_home_classId" 15 android:id="@+id/edt_home_classId"
16 android:layout_width="match_parent" 16 android:layout_width="match_parent"
17 android:layout_height="wrap_content" 17 android:layout_height="wrap_content"
18 - android:text="1184939098"/> 18 + android:text="1573557360"/>
19 <TextView 19 <TextView
20 android:layout_width="match_parent" 20 android:layout_width="match_parent"
21 android:layout_height="wrap_content" 21 android:layout_height="wrap_content"
@@ -61,6 +61,7 @@ @@ -61,6 +61,7 @@
61 android:layout_width="match_parent" 61 android:layout_width="match_parent"
62 android:layout_height="wrap_content" 62 android:layout_height="wrap_content"
63 android:text="推视频" 63 android:text="推视频"
  64 + android:visibility="gone"
64 65
65 /> 66 />
66 67
@@ -69,6 +70,7 @@ @@ -69,6 +70,7 @@
69 android:layout_width="match_parent" 70 android:layout_width="match_parent"
70 android:layout_height="wrap_content" 71 android:layout_height="wrap_content"
71 android:text="推音频" 72 android:text="推音频"
  73 + android:visibility="gone"
72 74
73 /> 75 />
74 </LinearLayout> 76 </LinearLayout>
@@ -10,7 +10,8 @@ @@ -10,7 +10,8 @@
10 <FrameLayout 10 <FrameLayout
11 android:id="@+id/fl_videoview_container" 11 android:id="@+id/fl_videoview_container"
12 android:layout_width="match_parent" 12 android:layout_width="match_parent"
13 - android:layout_height="10dp"> 13 + android:layout_height="1dp"
  14 + android:visibility="gone">
14 15
15 <com.pili.pldroid.player.widget.PLVideoTextureView 16 <com.pili.pldroid.player.widget.PLVideoTextureView
16 android:id="@+id/img_playVideo_replay" 17 android:id="@+id/img_playVideo_replay"
@@ -25,26 +26,34 @@ @@ -25,26 +26,34 @@
25 android:id="@+id/surfaceview_playVideo" 26 android:id="@+id/surfaceview_playVideo"
26 android:layout_width="match_parent" 27 android:layout_width="match_parent"
27 android:layout_height="match_parent" /> 28 android:layout_height="match_parent" />
  29 + <FrameLayout
  30 + android:layout_width="match_parent"
  31 + android:layout_height="match_parent">
  32 +
28 <ImageView 33 <ImageView
29 android:id="@+id/img_playVideo_novideo" 34 android:id="@+id/img_playVideo_novideo"
30 android:layout_width="match_parent" 35 android:layout_width="match_parent"
31 android:layout_height="match_parent" 36 android:layout_height="match_parent"
32 android:background="@mipmap/novideo" 37 android:background="@mipmap/novideo"
33 /> 38 />
34 - </RelativeLayout>  
35 -<Button 39 + <Button
36 android:id="@+id/btn_videoPlay_exit" 40 android:id="@+id/btn_videoPlay_exit"
37 android:layout_width="wrap_content" 41 android:layout_width="wrap_content"
38 android:layout_height="wrap_content" 42 android:layout_height="wrap_content"
  43 + android:layout_gravity="right|bottom"
39 android:text="退出课堂,界面还在" 44 android:text="退出课堂,界面还在"
  45 + android:visibility="gone"
40 /> 46 />
  47 + </FrameLayout>
  48 +
  49 + </RelativeLayout>
  50 +
41 <android.support.design.widget.TabLayout 51 <android.support.design.widget.TabLayout
42 android:id="@+id/sliding_tabs" 52 android:id="@+id/sliding_tabs"
43 android:layout_width="match_parent" 53 android:layout_width="match_parent"
44 android:layout_height="wrap_content" 54 android:layout_height="wrap_content"
45 /> 55 />
46 -  
47 - <android.support.v4.view.ViewPager 56 + <com.mang.xdy.demo.widget.view.NoScrollViewPager
48 android:id="@+id/viewpager" 57 android:id="@+id/viewpager"
49 android:layout_width="match_parent" 58 android:layout_width="match_parent"
50 android:layout_height="0px" 59 android:layout_height="0px"
@@ -55,7 +64,8 @@ @@ -55,7 +64,8 @@
55 android:layout_width="match_parent" 64 android:layout_width="match_parent"
56 android:layout_height="wrap_content" 65 android:layout_height="wrap_content"
57 android:layout_alignParentBottom="true" 66 android:layout_alignParentBottom="true"
58 - android:visibility="invisible"> 67 +
  68 + android:visibility="gone">
59 69
60 <include 70 <include
61 layout="@layout/home_media_controller" 71 layout="@layout/home_media_controller"
  1 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:tools="http://schemas.android.com/tools"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + tools:context="com.mang.xdy.demo.fragment.PublishFragment">
  6 +
  7 + <!-- TODO: Update blank fragment layout -->
  8 + <SurfaceView
  9 + android:id="@+id/sur_publish"
  10 + android:layout_width="match_parent"
  11 + android:layout_height="200dp"
  12 + android:text="@string/hello_blank_fragment" />
  13 + <Button
  14 + android:id="@+id/btn_publish_gets"
  15 + android:layout_width="wrap_content"
  16 + android:layout_height="wrap_content"
  17 + android:text="获取推流地址,开始推流"
  18 + />
  19 + <Button
  20 + android:id="@+id/btn_publish_stop"
  21 + android:layout_width="wrap_content"
  22 + android:layout_height="wrap_content"
  23 + android:text="停止推流"
  24 + />
  25 +</FrameLayout>

12.4 KB | 宽: | 高:

25.7 KB | 宽: | 高:

  • 两方对比
  • 交换覆盖
  • 透明覆盖
1 <resources> 1 <resources>
2 <string name="app_name">学点云</string> 2 <string name="app_name">学点云</string>
  3 +
  4 + <!-- TODO: Remove or change this placeholder text -->
  5 + <string name="hello_blank_fragment">Hello blank fragment</string>
3 </resources> 6 </resources>
@@ -30,10 +30,12 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -30,10 +30,12 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
30 private final static String URL="http://h5.test.3mang.com/web/"; 30 private final static String URL="http://h5.test.3mang.com/web/";
31 private SurfaceView surface; 31 private SurfaceView surface;
32 private Button bt_stop; 32 private Button bt_stop;
  33 + private XdySdk xdySdk;
33 @Override 34 @Override
34 protected void onCreate(Bundle savedInstanceState) { 35 protected void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState); 36 super.onCreate(savedInstanceState);
36 setContentView(R.layout.activity_threeivity); 37 setContentView(R.layout.activity_threeivity);
  38 + xdySdk=XdySdk.getXdyInstance();
37 bt_three= (Button) findViewById(R.id.bt_three); 39 bt_three= (Button) findViewById(R.id.bt_three);
38 bt_video= (Button) findViewById(R.id.bt_video); 40 bt_video= (Button) findViewById(R.id.bt_video);
39 surface= (SurfaceView) findViewById(R.id.surface); 41 surface= (SurfaceView) findViewById(R.id.surface);
@@ -83,7 +85,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -83,7 +85,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
83 //// xdyPlayer.playVideo(url,surface); 85 //// xdyPlayer.playVideo(url,surface);
84 // XdySdk.setAsyncApi("playAudio",url,null,Threeivity.this); 86 // XdySdk.setAsyncApi("playAudio",url,null,Threeivity.this);
85 // XdySdk.setAsyncApi("playVideo",url,surface,Threeivity.this,new EventHande()); 87 // XdySdk.setAsyncApi("playVideo",url,surface,Threeivity.this,new EventHande());
86 - XdySdk.api("publishVideo",url,surface,Threeivity.this,new EventHande()); 88 + xdySdk.api("publishVideo",url,surface,Threeivity.this);
87 // xdyPlayer.playVideo("",surface); 89 // xdyPlayer.playVideo("",surface);
88 90
89 // XdyPublisherCore xdyPublisherCore=new XdyPublisherCore(Threeivity.this); 91 // XdyPublisherCore xdyPublisherCore=new XdyPublisherCore(Threeivity.this);
@@ -94,8 +96,10 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -94,8 +96,10 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
94 bt_stop.setOnClickListener(new View.OnClickListener() { 96 bt_stop.setOnClickListener(new View.OnClickListener() {
95 @Override 97 @Override
96 public void onClick(View v) { 98 public void onClick(View v) {
97 - XdySdk.onPlayStop(); 99 +// xdySdk.onPlayStop();
98 // XdySdk.onPublisherStop();; 100 // XdySdk.onPublisherStop();;
  101 +
  102 + xdySdk.api("leaveClass","");
99 } 103 }
100 }); 104 });
101 init(); 105 init();
@@ -115,7 +119,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -115,7 +119,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
115 case R.id.bt_paudio: 119 case R.id.bt_paudio:
116 //开始推送音频 120 //开始推送音频
117 String url= "rtmp://player.daniulive.com:1935/hls/stream";; 121 String url= "rtmp://player.daniulive.com:1935/hls/stream";;
118 - XdySdk.setAsyncApi("publishAudio",url,surface,Threeivity.this); 122 + xdySdk.api("publishAudio",url,surface,Threeivity.this);
119 break; 123 break;
120 case R.id.bt_stopaudiopub: 124 case R.id.bt_stopaudiopub:
121 //停止 125 //停止
@@ -130,7 +134,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -130,7 +134,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
130 " \"userId\": 0\n" + 134 " \"userId\": 0\n" +
131 "}"; 135 "}";
132 String ss=StringUtils.stringToJson(param,true); 136 String ss=StringUtils.stringToJson(param,true);
133 - XdySdk.api(id,ss); 137 + xdySdk.api(id,ss);
134 break; 138 break;
135 case R.id.bt_back: 139 case R.id.bt_back:
136 // String id="initRecordPlayback"; 140 // String id="initRecordPlayback";
@@ -143,7 +147,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -143,7 +147,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
143 // " \"userId\": 0\n" + 147 // " \"userId\": 0\n" +
144 // "}"; 148 // "}";
145 // String ss=StringUtils.stringToJson(param,true); 149 // String ss=StringUtils.stringToJson(param,true);
146 - XdySdk.api(ids,""); 150 + xdySdk.api(ids,"");
147 break; 151 break;
148 case R.id.bt_stopReco: 152 case R.id.bt_stopReco:
149 // String isd="stopRecordPlayback"; 153 // String isd="stopRecordPlayback";
@@ -158,7 +162,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -158,7 +162,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
158 String ids_new="getVideoPublishPath"; 162 String ids_new="getVideoPublishPath";
159 String tem="{ \"type\": \"live\"}"; 163 String tem="{ \"type\": \"live\"}";
160 String s= StringUtils.stringToJson(tem,true); 164 String s= StringUtils.stringToJson(tem,true);
161 - XdySdk.api(ids_new,s); 165 + xdySdk.api(ids_new,s);
162 166
163 167
164 break; 168 break;
@@ -184,7 +188,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -184,7 +188,7 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
184 // LogUtil.e("java_native",s+":"+s1); 188 // LogUtil.e("java_native",s+":"+s1);
185 // } 189 // }
186 // }); 190 // });
187 - XdySdk.api(id,parameter); 191 + xdySdk.api(id,parameter);
188 // XdySdk.getXdyInstance().setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() { 192 // XdySdk.getXdyInstance().setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() {
189 // @Override 193 // @Override
190 // public void onXdyAsyncMessageReceiver(String type, String response) { 194 // public void onXdyAsyncMessageReceiver(String type, String response) {
@@ -192,41 +196,41 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene @@ -192,41 +196,41 @@ public class Threeivity extends AppCompatActivity implements View.OnClickListene
192 // } 196 // }
193 // }); 197 // });
194 198
195 - XdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() {  
196 - @Override  
197 - public void onXdyAsyncMessageReceiver(String type, String response) {  
198 - XdyLogUtil.e("学点云static", type + ":" + response);  
199 -// if ("video_play".equals(type)) {  
200 -// MessageBean messageBean = new Gson().fromJson(response, MessageBean.class);  
201 -// if (messageBean != null) {  
202 -//// Intent intent = new Intent(Threeivity.this, SmartPlayer.class);  
203 -//// intent.putExtra("url", messageBean.getRtmpUrl() + "");  
204 -//// startActivity(intent);  
205 -// Toast.makeText(Threeivity.this, messageBean.getRtmpUrl(), Toast.LENGTH_SHORT).show();  
206 -//// SmartPlayerNoLayout smartPlayerNoLayout=new SmartPlayerNoLayout(surface,Threeivity.this); 199 +// XdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() {
  200 +// @Override
  201 +// public void onXdyAsyncMessageReceiver(String type, String response) {
  202 +// XdyLogUtil.e("学点云static", type + ":" + response);
  203 +//// if ("video_play".equals(type)) {
  204 +//// MessageBean messageBean = new Gson().fromJson(response, MessageBean.class);
  205 +//// if (messageBean != null) {
  206 +////// Intent intent = new Intent(Threeivity.this, SmartPlayer.class);
  207 +////// intent.putExtra("url", messageBean.getRtmpUrl() + "");
  208 +////// startActivity(intent);
  209 +//// Toast.makeText(Threeivity.this, messageBean.getRtmpUrl(), Toast.LENGTH_SHORT).show();
  210 +////// SmartPlayerNoLayout smartPlayerNoLayout=new SmartPlayerNoLayout(surface,Threeivity.this);
  211 +//// }
  212 +//// }
  213 +// if("live".equals(type)){
  214 +//// String urls= "rtmp://player.daniulive.com:1935/hls/stream";;
  215 +// String url = XdyStringUtils.stringToJson(response);
  216 +// XdyLogUtil.e("调用任务了播视频了url:",""+url);
  217 +// String us=response.substring(1,response.length()-1);
  218 +// XdyLogUtil.e("调用任务了播视频了ursfdfl:",""+us);
  219 +// try {
  220 +//
  221 +// LiveBean liveBean = new Gson().fromJson(url, LiveBean.class);
  222 +//
  223 +// if (liveBean != null) {
  224 +// XdySdk.setAsyncApi("publishVideo", liveBean.getPublishUrl(), surface, Threeivity.this);
  225 +// XdyLogUtil.e("调用任务了播视频了","哈哈哈哈");
207 // } 226 // }
  227 +// }catch (Exception e){
  228 +// XdyLogUtil.e("调用任务了播视频了e",""+e.getMessage());
  229 +// XdyLogUtil.e("调用任务了播视频了url:",""+url);
208 // } 230 // }
209 - if("live".equals(type)){  
210 -// String urls= "rtmp://player.daniulive.com:1935/hls/stream";;  
211 - String url = XdyStringUtils.stringToJson(response);  
212 - XdyLogUtil.e("调用任务了播视频了url:",""+url);  
213 - String us=response.substring(1,response.length()-1);  
214 - XdyLogUtil.e("调用任务了播视频了ursfdfl:",""+us);  
215 - try {  
216 -  
217 - LiveBean liveBean = new Gson().fromJson(url, LiveBean.class);  
218 -  
219 - if (liveBean != null) {  
220 - XdySdk.setAsyncApi("publishVideo", liveBean.getPublishUrl(), surface, Threeivity.this);  
221 - XdyLogUtil.e("调用任务了播视频了","哈哈哈哈");  
222 - }  
223 - }catch (Exception e){  
224 - XdyLogUtil.e("调用任务了播视频了e",""+e.getMessage());  
225 - XdyLogUtil.e("调用任务了播视频了url:",""+url);  
226 - }  
227 - }  
228 - }  
229 - }); 231 +// }
  232 +// }
  233 +// });
230 } 234 }
231 public void playMedia(){ 235 public void playMedia(){
232 Intent intent = new Intent(Intent.ACTION_VIEW); 236 Intent intent = new Intent(Intent.ACTION_VIEW);
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 <activity android:name=".MainActivity"> 20 <activity android:name=".MainActivity">
21 <intent-filter> 21 <intent-filter>
22 <action android:name="android.intent.action.MAIN" /> 22 <action android:name="android.intent.action.MAIN" />
  23 +
23 <category android:name="android.intent.category.LAUNCHER" /> 24 <category android:name="android.intent.category.LAUNCHER" />
24 </intent-filter> 25 </intent-filter>
25 </activity> 26 </activity>
@@ -34,6 +35,7 @@ @@ -34,6 +35,7 @@
34 android:name=".PLVideoTextureActivity" 35 android:name=".PLVideoTextureActivity"
35 android:theme="@style/AppThemeFullscreen" /> 36 android:theme="@style/AppThemeFullscreen" />
36 <activity android:name=".VideoFileActivity" /> 37 <activity android:name=".VideoFileActivity" />
  38 + <activity android:name="com.xdy.abao.ClassexitActivity"></activity>
37 </application> 39 </application>
38 40
39 </manifest> 41 </manifest>
  1 +package com.xdy.abao;
  2 +
  3 +import android.support.v7.app.AppCompatActivity;
  4 +import android.os.Bundle;
  5 +
  6 +import com.pili.pldroid.playerdemo.R;
  7 +
  8 +public class ClassexitActivity extends AppCompatActivity {
  9 +
  10 + @Override
  11 + protected void onCreate(Bundle savedInstanceState) {
  12 + super.onCreate(savedInstanceState);
  13 + setContentView(R.layout.activity_classexit);
  14 + }
  15 +}
  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:id="@+id/activity_classexit"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + android:paddingBottom="@dimen/activity_vertical_margin"
  8 + android:paddingLeft="@dimen/activity_horizontal_margin"
  9 + android:paddingRight="@dimen/activity_horizontal_margin"
  10 + android:paddingTop="@dimen/activity_vertical_margin"
  11 + tools:context="com.xdy.abao.ClassexitActivity">
  12 +
  13 +</RelativeLayout>
@@ -170,6 +170,8 @@ public interface Constants { @@ -170,6 +170,8 @@ public interface Constants {
170 * 获取Audio推流地址 170 * 获取Audio推流地址
171 */ 171 */
172 String GET_AUDIO_PUBLISH_PATH="getAudioPublishPath"; 172 String GET_AUDIO_PUBLISH_PATH="getAudioPublishPath";
  173 +
  174 + String UN_PUBLISH_VIDEO="unPublishVideo";
173 /*Context为空的时候给出的提示*/ 175 /*Context为空的时候给出的提示*/
174 String ERROR_CONTENT_NULL="Xdy,init context is null"; 176 String ERROR_CONTENT_NULL="Xdy,init context is null";
175 /*判断XdyCore是否被初始化*/ 177 /*判断XdyCore是否被初始化*/
@@ -194,4 +196,9 @@ public interface Constants { @@ -194,4 +196,9 @@ public interface Constants {
194 * 推流成功 196 * 推流成功
195 */ 197 */
196 String PUBLISH_RERUEN_SUCCESS="publishSuccess"; 198 String PUBLISH_RERUEN_SUCCESS="publishSuccess";
  199 +
  200 + /**
  201 + * 播放音视频,出现画面, 同时返回id
  202 + */
  203 + String PLAY_SUCCESS="play_success";
197 } 204 }
@@ -8,6 +8,9 @@ public class APIContants { @@ -8,6 +8,9 @@ public class APIContants {
8 /*与js调用设置的常量*/ 8 /*与js调用设置的常量*/
9 protected final static String NATIVE_JS_LINK="xdyAndroid"; 9 protected final static String NATIVE_JS_LINK="xdyAndroid";
10 /*baseUrl*/ 10 /*baseUrl*/
  11 +// protected final static String BASE_URL="http://192.168.1.118/xdysdk/web/";
  12 +
  13 +// protected final static String BASE_URL="http://192.168.1.109/xdysdk/web/";
11 protected final static String BASE_URL="http://h5.test.3mang.com/web/"; 14 protected final static String BASE_URL="http://h5.test.3mang.com/web/";
12 15
13 } 16 }
@@ -6,6 +6,7 @@ package com.mang.xdy.core; @@ -6,6 +6,7 @@ package com.mang.xdy.core;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Build; 8 import android.os.Build;
  9 +import android.text.NoCopySpan;
9 import android.text.TextUtils; 10 import android.text.TextUtils;
10 import android.webkit.JavascriptInterface; 11 import android.webkit.JavascriptInterface;
11 import android.webkit.ValueCallback; 12 import android.webkit.ValueCallback;
@@ -24,7 +25,6 @@ public class XdyJsCore { @@ -24,7 +25,6 @@ public class XdyJsCore {
24 private WebView mWebView; 25 private WebView mWebView;
25 private static String TAG="xdyjscore"; 26 private static String TAG="xdyjscore";
26 private static XdyJsCore mXdyCore; 27 private static XdyJsCore mXdyCore;
27 - protected boolean isDestroy=false;  
28 private XdyJavaScript mXdyJavaScript; 28 private XdyJavaScript mXdyJavaScript;
29 /** 29 /**
30 * 异步对外回调接口,所有回调都在此完成 30 * 异步对外回调接口,所有回调都在此完成
@@ -46,20 +46,20 @@ public class XdyJsCore { @@ -46,20 +46,20 @@ public class XdyJsCore {
46 } 46 }
47 init(context); 47 init(context);
48 } 48 }
49 -  
50 /** 49 /**
51 * 初始化 50 * 初始化
52 * @param context 51 * @param context
53 */ 52 */
54 protected void init(Context context){ 53 protected void init(Context context){
  54 + if(context==null){
  55 + return;
  56 + }
55 //清理Webview缓存数据库 57 //清理Webview缓存数据库
56 - 58 + mXdyJavaScript=new XdyJavaScript();
57 mWebView=new WebView(context); 59 mWebView=new WebView(context);
58 WebSettings webSettings=mWebView.getSettings(); 60 WebSettings webSettings=mWebView.getSettings();
59 webSettings.setJavaScriptEnabled(true); 61 webSettings.setJavaScriptEnabled(true);
60 - mWebView.getSettings().setAppCacheEnabled(false);  
61 - webSettings. setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存  
62 - mXdyJavaScript=new XdyJavaScript(); 62 + webSettings.setAppCacheEnabled(false);
63 mWebView.addJavascriptInterface(mXdyJavaScript, APIContants.NATIVE_JS_LINK); 63 mWebView.addJavascriptInterface(mXdyJavaScript, APIContants.NATIVE_JS_LINK);
64 mWebView.setWebChromeClient(new WebChromeClient(){ 64 mWebView.setWebChromeClient(new WebChromeClient(){
65 @Override 65 @Override
@@ -76,7 +76,12 @@ public class XdyJsCore { @@ -76,7 +76,12 @@ public class XdyJsCore {
76 } 76 }
77 }); 77 });
78 } 78 }
79 - 79 + @Deprecated
  80 + public void reSetXdyJavaScript(){
  81 + mXdyJavaScript=new XdyJavaScript();
  82 + mWebView.removeJavascriptInterface(APIContants.NATIVE_JS_LINK);
  83 + mWebView.addJavascriptInterface(mXdyJavaScript, APIContants.NATIVE_JS_LINK);
  84 + }
80 /** 85 /**
81 * 获取XdyCore实例 86 * 获取XdyCore实例
82 * @param context 87 * @param context
@@ -113,42 +118,17 @@ public class XdyJsCore { @@ -113,42 +118,17 @@ public class XdyJsCore {
113 * @param parameter 118 * @param parameter
114 */ 119 */
115 protected void native2js( String id, String parameter) { 120 protected void native2js( String id, String parameter) {
116 - XdyLogUtil.e("推流线程native2js:",Thread.currentThread().getId()+""); 121 + XdyLogUtil.e("推流线程native2js:",Thread.currentThread().getId()+"id:"+id);
117 122
118 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 123 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
119 mWebView.evaluateJavascript("javascript:_native2js('" + id + "','"+parameter+"')", new ValueCallback<String>() { 124 mWebView.evaluateJavascript("javascript:_native2js('" + id + "','"+parameter+"')", new ValueCallback<String>() {
120 @Override 125 @Override
121 public void onReceiveValue(String value) { 126 public void onReceiveValue(String value) {
122 XdyLogUtil.e(TAG+"同步获取的数据", value); 127 XdyLogUtil.e(TAG+"同步获取的数据", value);
123 - //TODO  
124 -// if (!TextUtils.isEmpty(value)&&value.length()>10) {  
125 -// if(mOnXdyAsyncMessageListener !=null){  
126 -// mOnXdyAsyncMessageListener.getSdyAsyncMessageListener("live",value);  
127 -// }  
128 -// }  
129 -// if (!TextUtils.isEmpty(value)&&value.length()>10) {  
130 -// if(mOnXdyAsyncMessageListener !=null){  
131 -// mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,value);  
132 -// }  
133 -// }  
134 } 128 }
135 }); 129 });
136 }else{ 130 }else{
137 mWebView.loadUrl("javascript:_native2js('" + id + "','"+parameter+"')"); 131 mWebView.loadUrl("javascript:_native2js('" + id + "','"+parameter+"')");
138 } 132 }
139 -  
140 - }  
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 } 133 }
154 } 134 }
@@ -46,6 +46,7 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC @@ -46,6 +46,7 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC
46 protected int video_opt = 1; 46 protected int video_opt = 1;
47 int videoWidth = 640; 47 int videoWidth = 640;
48 private int videoHight = 480; 48 private int videoHight = 480;
  49 + /*是否推流的标志,true 开始推送,false不推送*/
49 private boolean isStart = false; 50 private boolean isStart = false;
50 /*是否支持硬编码 默认不支持*/ 51 /*是否支持硬编码 默认不支持*/
51 private boolean is_hardware_encoder = false; 52 private boolean is_hardware_encoder = false;
@@ -191,8 +192,10 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC @@ -191,8 +192,10 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC
191 private void initCamera(SurfaceHolder holder) { 192 private void initCamera(SurfaceHolder holder) {
192 Log.i(TAG, "initCamera.."); 193 Log.i(TAG, "initCamera..");
193 194
194 - if (mPreviewRunning) 195 + if (mPreviewRunning) {
  196 + if(mCamera!=null)
195 mCamera.stopPreview(); 197 mCamera.stopPreview();
  198 + }
196 199
197 Camera.Parameters parameters; 200 Camera.Parameters parameters;
198 try { 201 try {
@@ -429,6 +432,24 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC @@ -429,6 +432,24 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC
429 isStart=false; 432 isStart=false;
430 } 433 }
431 434
  435 + /**
  436 + * onPause 方法调用,不释放相机资源
  437 + */
  438 + protected void onPausePublisher(){
  439 + isStart=false;
  440 + if (audioRecord_ != null) {
  441 + XdyLogUtil.i(TAG, "surfaceDestroyed, call StopRecording..");
  442 + audioRecord_.StopRecording();
  443 + audioRecord_ = null;
  444 + }
  445 + if (xdyPublisher != null) {
  446 + xdyPublisher.SmartPublisherStop();
  447 + }
  448 + }
  449 + public void onResumePublisher(){
  450 + isStart=true;
  451 + }
  452 +
432 private int setHardwareEncoderKbps(int width, int height) 453 private int setHardwareEncoderKbps(int width, int height)
433 { 454 {
434 int hwEncoderKpbs = 0; 455 int hwEncoderKpbs = 0;
@@ -59,6 +59,8 @@ public class XdySdk implements SubjectListener{ @@ -59,6 +59,8 @@ 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 + /*推流重连状态,如果是重连状态会有一系列加入课堂的情况*/
  63 + private boolean isReconnection=false;
62 /*观察者集合*/ 64 /*观察者集合*/
63 private List<ObserverListener> observerListenerList=new ArrayList<ObserverListener>(); 65 private List<ObserverListener> observerListenerList=new ArrayList<ObserverListener>();
64 66
@@ -82,13 +84,13 @@ public class XdySdk implements SubjectListener{ @@ -82,13 +84,13 @@ public class XdySdk implements SubjectListener{
82 } 84 }
83 85
84 /** 86 /**
85 - * 清除信息 87 + * 退出时清除信息(重置js监听)
86 */ 88 */
87 public void removeAll(){ 89 public void removeAll(){
88 // if(observerListenerList!=null){ 90 // if(observerListenerList!=null){
89 // observerListenerList.clear(); 91 // observerListenerList.clear();
90 // } 92 // }
91 - mXdyJsCore.onDestroy(); 93 +// mXdyJsCore.init(mContext);
92 } 94 }
93 95
94 /** 96 /**
@@ -169,21 +171,18 @@ public class XdySdk implements SubjectListener{ @@ -169,21 +171,18 @@ public class XdySdk implements SubjectListener{
169 judgeCore(); 171 judgeCore();
170 //再次停止播放器 172 //再次停止播放器
171 switch (type){ 173 switch (type){
172 - case "unPublishAudio":  
173 - //停止推送音频  
174 - case "unPublishVideo":  
175 - //停止推流video(关闭视频:根据api)  
176 - onPublisherStop();  
177 - break; 174 +// case "unPublishAudio":
  175 +// //停止推送音频
  176 +// case "unPublishVideo":
  177 +// //停止推流video(关闭视频:根据api)
  178 +// onPublisherStop();
  179 +// break;
178 case "stopAudio": 180 case "stopAudio":
179 //停止播放audio() 181 //停止播放audio()
180 case"stopVideo": 182 case"stopVideo":
181 //停止播放video( 停止播放:根据api) 183 //停止播放video( 停止播放:根据api)
182 // onPlayStop(); 184 // onPlayStop();
183 break; 185 break;
184 - case "init":  
185 - mXdyJsCore.isDestroy=false;  
186 - break;  
187 } 186 }
188 handler.post(new Runnable() { 187 handler.post(new Runnable() {
189 @Override 188 @Override
@@ -332,6 +331,7 @@ public class XdySdk implements SubjectListener{ @@ -332,6 +331,7 @@ public class XdySdk implements SubjectListener{
332 // String publishPath=XdyStringUtils.stringToJson(response); 331 // String publishPath=XdyStringUtils.stringToJson(response);
333 String publishPath=response; 332 String publishPath=response;
334 GetPublishPathReceiveBean getPublishPathReceiveBean=JsonUtil.parseJsonToBean(publishPath,GetPublishPathReceiveBean.class); 333 GetPublishPathReceiveBean getPublishPathReceiveBean=JsonUtil.parseJsonToBean(publishPath,GetPublishPathReceiveBean.class);
  334 +
335 if(getPublishPathReceiveBean!=null) { 335 if(getPublishPathReceiveBean!=null) {
336 //可以推流了 336 //可以推流了
337 if (getPublishPathReceiveBean.getCode() == 0) { 337 if (getPublishPathReceiveBean.getCode() == 0) {
@@ -350,6 +350,8 @@ public class XdySdk implements SubjectListener{ @@ -350,6 +350,8 @@ public class XdySdk implements SubjectListener{
350 if (mXdyPublisherCore == null) { 350 if (mXdyPublisherCore == null) {
351 mXdyPublisherCore = new XdyPublisherCore(1, 1, mActivity); 351 mXdyPublisherCore = new XdyPublisherCore(1, 1, mActivity);
352 } 352 }
  353 + publish_url=video_url;
  354 + isPublisher=true;
353 mXdyPublisherCore.publisher(video_url,mSurfaceView, new EventHande()); 355 mXdyPublisherCore.publisher(video_url,mSurfaceView, new EventHande());
354 // PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); 356 // PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH));
355 //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断) 357 //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断)
@@ -386,6 +388,7 @@ public class XdySdk implements SubjectListener{ @@ -386,6 +388,7 @@ public class XdySdk implements SubjectListener{
386 if(mXdyPublisherCore==null) 388 if(mXdyPublisherCore==null)
387 mXdyPublisherCore=new XdyPublisherCore(1,0,mActivity); 389 mXdyPublisherCore=new XdyPublisherCore(1,0,mActivity);
388 mXdyPublisherCore.publisherAudio(audio_url,new EventHande()); 390 mXdyPublisherCore.publisherAudio(audio_url,new EventHande());
  391 + isPublisher=true;
389 //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断) 392 //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断)
390 PlayerUtils.setPublishSendSuccessAudio(audio_url); 393 PlayerUtils.setPublishSendSuccessAudio(audio_url);
391 }else{ 394 }else{
@@ -402,7 +405,7 @@ public class XdySdk implements SubjectListener{ @@ -402,7 +405,7 @@ public class XdySdk implements SubjectListener{
402 if(publisherVideoReturnBean_audio!=null&&publisherVideoReturnBean_audio.getCode()==0){ 405 if(publisherVideoReturnBean_audio!=null&&publisherVideoReturnBean_audio.getCode()==0){
403 XdyLogUtil.e(TAG,"后台成功接收到,推流的地址"); 406 XdyLogUtil.e(TAG,"后台成功接收到,推流的地址");
404 //TODO 407 //TODO
405 - isPublisher=true; 408 +
406 handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); 409 handleListener(Constants.PUBLISH_RERUEN_SUCCESS,"");
407 }else{ 410 }else{
408 //TODO 411 //TODO
@@ -447,15 +450,46 @@ public class XdySdk implements SubjectListener{ @@ -447,15 +450,46 @@ public class XdySdk implements SubjectListener{
447 if(errorCodeEntity!=null){ 450 if(errorCodeEntity!=null){
448 if(errorCodeEntity.getCode()==Constants.LEAVE_CLASS_CODE){ 451 if(errorCodeEntity.getCode()==Constants.LEAVE_CLASS_CODE){
449 /** 452 /**
450 - * 正在直播的时候mcu无故断开,需要重新连接 453 + * 方案 一 1,正在直播的时候mcu无故断开,需要重新连接
  454 + * 2,class exit 时候主动课堂停止,停止推流
  455 + * 利用mcu的生命周期,加入课堂成功后去请求数据
451 */ 456 */
452 - //mcu 断开,页面也断开,用户需要重新调用  
453 -// if(isPublisher) { 457 + // 方案 二 mcu 断开,页面也断开,用户需要手动重新调用
  458 + if(isPublisher) {
454 // onPublisherStop(); 459 // onPublisherStop();
455 // api("publishVideo", "", mSurfaceView, mActivity); 460 // api("publishVideo", "", mSurfaceView, mActivity);
456 -// } 461 + isReconnection=true;
  462 +// XdyLogUtil.e("mcu 断线了重连","断线重连,使用的都是同一个保存的url");
  463 +// api(Constants.UN_PUBLISH_VIDEO,"");
  464 +// setPublishSendSuccessVideo(publish_url);
  465 +// getPublishPathVideo();
  466 + }
  467 +// onPublisherStop();
  468 + }
  469 + }
  470 + handleListener(type,response);
  471 + break;
  472 + case Constants.CLASS_EXIT:
  473 + /**
  474 + * 处理正在推流视频,课堂退出的情况,(用户操作退出界面)
  475 + * 此时,停止推流,清除surfaceview Activtity 数据,url数据
  476 + */
  477 + if(isPublisher){
  478 +
457 onPublisherStop(); 479 onPublisherStop();
  480 +
458 } 481 }
  482 + handleListener(type,response);
  483 + break;
  484 + case Constants.CLASS_JOIN_SUCCESS:
  485 + if(isReconnection){
  486 +// api("stopPublishVideo","");
  487 +// if(mXdyPublisherCore!=null){
  488 +// mXdyPublisherCore.onStopPublisher();
  489 +// mXdyPublisherCore=null;
  490 +// }
  491 +// getPublishPathVideo();;
  492 +// setPublishSendSuccessVideo(publish_url);
459 } 493 }
460 handleListener(type,response); 494 handleListener(type,response);
461 break; 495 break;
@@ -491,11 +525,23 @@ public class XdySdk implements SubjectListener{ @@ -491,11 +525,23 @@ public class XdySdk implements SubjectListener{
491 if (mXdyPlayerCore != null) { 525 if (mXdyPlayerCore != null) {
492 mXdyPlayerCore.onStopPlay(); 526 mXdyPlayerCore.onStopPlay();
493 // mXdyPlayerCore = null; 527 // mXdyPlayerCore = null;
  528 +
494 } 529 }
495 return true; 530 return true;
496 } 531 }
497 return false; 532 return false;
498 } 533 }
  534 + /**
  535 + * onPause 暂停所有的,退出都在这里
  536 + */
  537 + public void onPlayPauseAll(){
  538 + if(mXdyPlayerCore!=null) {
  539 + mXdyPlayerCore.onPause();
  540 + }
  541 + if(mXdyJsCore!=null) {
  542 + mXdyJsCore.init(mContext);
  543 + }
  544 + }
499 545
500 /** 546 /**
501 * 结束时调用 547 * 结束时调用
@@ -526,42 +572,65 @@ public class XdySdk implements SubjectListener{ @@ -526,42 +572,65 @@ public class XdySdk implements SubjectListener{
526 mActivity = null; 572 mActivity = null;
527 } 573 }
528 } 574 }
529 -// isPublisher=false; 575 + isPublisher=false;
  576 + isReconnection=false;
  577 + }
  578 +
  579 + /**
  580 + * onPause 方法时走的周期
  581 + */
  582 + public void onPublisherPause(){
  583 + if(mXdyPublisherCore!=null){
  584 + mXdyPublisherCore.onPausePublisher();
  585 + }
530 } 586 }
  587 +private String publish_url="";
  588 + /**
  589 + * onResume 调用,目前是空方法
  590 + * TODO 只有一个boolean
  591 + */
  592 + public void onPublisherResume(){
  593 + if(mXdyPublisherCore!=null) {
  594 + mXdyPublisherCore.onResumePublisher();
531 595
  596 + if (!TextUtils.isEmpty(publish_url)) {
  597 + mXdyPublisherCore.publisher(publish_url, mSurfaceView, new EventHande());
  598 + }
  599 + }
  600 + }
532 class EventHande implements SmartEventCallback { 601 class EventHande implements SmartEventCallback {
533 @Override 602 @Override
534 public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) { 603 public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) {
535 switch (code) { 604 switch (code) {
536 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED: 605 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED:
537 - Log.i(TAG, "开始。。"); 606 + Log.e(TAG, "开始。。");
538 break; 607 break;
539 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING: 608 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING:
540 - Log.i(TAG, "连接中。。"); 609 + Log.e(TAG, "连接中。。");
541 break; 610 break;
542 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED: 611 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED:
543 - Log.i(TAG, "连接失败。。"); 612 + Log.e(TAG, "连接失败。。");
544 break; 613 break;
545 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED: 614 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED:
546 - Log.i(TAG, "连接成功。。"); 615 + Log.e(TAG, "连接成功。。");
547 //TODO //如果连接成功发送连接成功信息,判断的方式有待考虑 616 //TODO //如果连接成功发送连接成功信息,判断的方式有待考虑
548 // PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); 617 // PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH));
549 // XdySdk.getXdyInstance().notifyObserver("video_success",""); 618 // XdySdk.getXdyInstance().notifyObserver("video_success","");
550 break; 619 break;
551 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED: 620 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED:
552 - Log.i(TAG, "连接断开。。"); 621 + Log.e(TAG, "连接断开。。");
553 break; 622 break;
554 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP: 623 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP:
555 Log.i(TAG, "关闭。。"); 624 Log.i(TAG, "关闭。。");
556 notifyObserver("play_stop",currentPlayId+""); 625 notifyObserver("play_stop",currentPlayId+"");
557 break; 626 break;
558 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO: 627 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO:
559 - Log.i(TAG, "分辨率信息: width: " + param1 + ", height: " + param2); 628 + Log.e(TAG, "分辨率信息: width: " + param1 + ", height: " + param2);
560 //在这里最接近得到播放的成功的准确回调 629 //在这里最接近得到播放的成功的准确回调
561 - notifyObserver("video_success",currentPlayId+""); 630 + notifyObserver(Constants.PLAY_SUCCESS,currentPlayId+"");
562 break; 631 break;
563 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED: 632 case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED:
564 - Log.i(TAG, "收不到媒体数据,可能是url错误。。"); 633 + Log.e(TAG, "收不到媒体数据,可能是url错误。。");
565 } 634 }
566 635
567 } 636 }
@@ -6,9 +6,8 @@ import com.mang.xdy.bean.ErrorCodeEntity; @@ -6,9 +6,8 @@ import com.mang.xdy.bean.ErrorCodeEntity;
6 /** 6 /**
7 * Created by abao on 2017/4/13. 7 * Created by abao on 2017/4/13.
8 * 对外返回错误信息 8 * 对外返回错误信息
9 - * 9 + *@deprecated
10 */ 10 */
11 -  
12 public class MsgManage { 11 public class MsgManage {
13 private MsgManage(){} 12 private MsgManage(){}
14 private static class ErrorInner{ 13 private static class ErrorInner{
  1 +package com.mang.xdy.utils;
  2 +
  3 +
  4 +import android.content.Context;
  5 +import android.net.ConnectivityManager;
  6 +import android.net.NetworkInfo;
  7 +import android.telephony.TelephonyManager;
  8 +
  9 +
  10 +/**
  11 + * 网络工具类
  12 + */
  13 +public class NetWorkUtils {
  14 + private NetWorkUtils(){
  15 + /* cannot be instantiated */
  16 + throw new UnsupportedOperationException("cannot be instantiated");
  17 + }
  18 +
  19 + /**
  20 + * 判断是否有网络连接
  21 + * @param context
  22 + * @return
  23 + */
  24 + public static boolean isNetworkConnected(Context context) {
  25 + if (context != null) {
  26 + ConnectivityManager mConnectivityManager = (ConnectivityManager) context
  27 + .getSystemService(Context.CONNECTIVITY_SERVICE);
  28 + NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
  29 + if (mNetworkInfo != null) {
  30 + return mNetworkInfo.isAvailable();
  31 + }
  32 + }
  33 + return false;
  34 + }
  35 +
  36 +
  37 + /**
  38 + * 判断WIFI网络是否可用
  39 + * @param context
  40 + * @return
  41 + */
  42 + public static boolean isWifiConnected(Context context) {
  43 + if (context != null) {
  44 + ConnectivityManager mConnectivityManager = (ConnectivityManager) context
  45 + .getSystemService(Context.CONNECTIVITY_SERVICE);
  46 + NetworkInfo mWiFiNetworkInfo = mConnectivityManager
  47 + .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
  48 + if (mWiFiNetworkInfo != null) {
  49 + return mWiFiNetworkInfo.isAvailable();
  50 + }
  51 + }
  52 + return false;
  53 + }
  54 +
  55 +
  56 + /**
  57 + * 判断MOBILE网络是否可用
  58 + * @param context
  59 + * @return
  60 + */
  61 + public static boolean isMobileConnected(Context context) {
  62 + if (context != null) {
  63 + ConnectivityManager mConnectivityManager = (ConnectivityManager) context
  64 + .getSystemService(Context.CONNECTIVITY_SERVICE);
  65 + NetworkInfo mMobileNetworkInfo = mConnectivityManager
  66 + .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
  67 + if (mMobileNetworkInfo != null) {
  68 + return mMobileNetworkInfo.isAvailable();
  69 + }
  70 + }
  71 + return false;
  72 + }
  73 +
  74 +
  75 + /**
  76 + * 获取当前网络连接的类型信息
  77 + * @param context
  78 + * @return
  79 + */
  80 + public static int getConnectedType(Context context) {
  81 + if (context != null) {
  82 + ConnectivityManager mConnectivityManager = (ConnectivityManager) context
  83 + .getSystemService(Context.CONNECTIVITY_SERVICE);
  84 + NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
  85 + if (mNetworkInfo != null && mNetworkInfo.isAvailable()) {
  86 + return mNetworkInfo.getType();
  87 + }
  88 + }
  89 + return -1;
  90 + }
  91 +
  92 +
  93 + /**
  94 + * 获取当前的网络状态 :没有网络0:WIFI网络1:3G网络2:2G网络3
  95 + *
  96 + * @param context
  97 + * @return
  98 + */
  99 + public static int getAPNType(Context context) {
  100 + int netType = 0;
  101 + ConnectivityManager connMgr = (ConnectivityManager) context
  102 + .getSystemService(Context.CONNECTIVITY_SERVICE);
  103 + NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
  104 + if (networkInfo == null) {
  105 + return netType;
  106 + }
  107 + int nType = networkInfo.getType();
  108 + if (nType == ConnectivityManager.TYPE_WIFI) {
  109 + netType = 1;// wifi
  110 + } else if (nType == ConnectivityManager.TYPE_MOBILE) {
  111 + int nSubType = networkInfo.getSubtype();
  112 + TelephonyManager mTelephony = (TelephonyManager) context
  113 + .getSystemService(Context.TELEPHONY_SERVICE);
  114 + if (nSubType == TelephonyManager.NETWORK_TYPE_UMTS
  115 + && !mTelephony.isNetworkRoaming()) {
  116 + netType = 2;// 3G
  117 + } else {
  118 + netType = 3;// 2G
  119 + }
  120 + }
  121 + return netType;
  122 + }
  123 +}
This file is too large to display.
This file is too large to display.
This file is too large to display.