Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
huangxinbao
/
Android_Sdk
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
huangxinbao
2017-05-02 22:41:26 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
739771b37ef3f8dff9c7d995e2d15e8d8e053a27
739771b3
1 parent
7eab6325
Modify push video will be play their wom problem
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
538 行增加
和
484 行删除
MyApplication/XdyDemo/src/main/java/com/mang/xdy/demo/activity/VideoPublisherActivity.java
MyApplication/XdyDemo/src/main/java/com/mang/xdy/demo/widget/view/AutoAdaptHeaderViewGroup.java
MyApplication/XdyDemo/src/main/res/mipmap-xxhdpi/camerap_normal2x.png
MyApplication/XdyDemo/src/main/res/mipmap-xxhdpi/hangup_normal2x.png
MyApplication/XdyDemo/src/main/java/com/mang/xdy/demo/activity/VideoPublisherActivity.java
查看文件 @
739771b
//package com.mang.xdy.demo.activity;
//
// import android.app.AlertDialog;
// import android.app.Dialog;
// import android.content.Context;
// import android.content.DialogInterface;
// import android.media.Image;
// import android.os.Bundle;
// import android.os.Handler;
// import android.os.Message;
// import android.support.design.widget.TabLayout;
// import android.support.v4.view.ViewPager;
// import android.support.v7.app.AppCompatActivity;
// import android.text.TextUtils;
// import android.util.Log;
// import android.view.Gravity;
// import android.view.SurfaceView;
// import android.view.View;
// import android.view.Window;
// import android.view.WindowManager;
// import android.widget.Button;
// import android.widget.EditText;
// import android.widget.ImageView;
// import android.widget.TextView;
// import android.widget.Toast;
//
// import com.eventhandle.SmartEventCallback;
// import com.google.gson.Gson;
// import com.mang.xdy.common.Constants;
// import com.mang.xdy.core.XdySdk;
// import com.mang.xdy.demo.R;
// import com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter;
// import com.mang.xdy.demo.bean.AudioPlayBean;
// import com.mang.xdy.demo.bean.ChatBean;
// import com.mang.xdy.demo.bean.DocEntity;
// import com.mang.xdy.demo.bean.ErrorEntity;
// import com.mang.xdy.demo.bean.InitClassSuccessEntity;
// import com.mang.xdy.demo.bean.JoinClass;
// import com.mang.xdy.demo.bean.LiveBean;
// import com.mang.xdy.demo.bean.PublisherEntity;
// import com.mang.xdy.demo.bean.PublisherVideoExitBean;
// import com.mang.xdy.demo.bean.PublisherVideoReturnBean;
// import com.mang.xdy.demo.bean.VideoPlayBean;
// import com.mang.xdy.demo.utils.JsonUtil;
// import com.mang.xdy.demo.utils.ToastUtil;
// import com.mang.xdy.demo.widget.dialog.LoginDialog;
// import com.mang.xdy.listener.ObserverListener;
// import com.mang.xdy.utils.UIUtils;
// import com.mang.xdy.utils.XdyLogUtil;
// import com.mang.xdy.utils.XdyStringUtils;
//
// import butterknife.BindView;
// import butterknife.ButterKnife;
// import butterknife.OnClick;
//
//public class VideoPublisherActivity extends AppCompatActivity implements ObserverListener{
// private final static String TAG = "VideoPlayActivity";
// @BindView(R.id.btn_videoPlay_pubsherVideo)
// Button btnVideoPlayPubsherVideo;
// @BindView(R.id.btn_videoPlay_chat)
// Button btnVideoPlayChat;
// @BindView(R.id.tv_videoPlay_url)
// TextView tv_videoPlay_url;
// @BindView(R.id.surfaceview_pubisherVideo)
// SurfaceView surfaceview_pubisherVideo;
// @BindView(R.id.btn_videoPlay_publisherAudio)
// Button btn_videoPlay_publisherAudio;
//// @BindView(R.id.img_playVideo_novideo)
//// ImageView img_playVideo_novideo;
// private String username="";
// private String userpwd="";
// private PersonDialog personDialog;
// private SimpleFragmentPagerAdapter pagerAdapter;
// private XdySdk xdySdk;
// private ViewPager viewPager;
// //默认推送视频
// private boolean isPusherAudio=false;
// /*默认是可以退出的,如果进行推流则需要主动退出*/
// private boolean isAbleback=false;
// private TabLayout tabLayout;
// @BindView(R.id.surfaceview_playVideo)
// SurfaceView surfaceviewPlayVideo;
// @BindView(R.id.btn_videoPlay_stop)
// Button btn_videoPlay_stop;
// private String initClass = "";
// private String publisherSuccess="";
// /*视频成功返回值*/
// private PublisherVideoReturnBean publisherVideoReturnBean;
// private Handler handler = new Handler() {
// @Override
// public void handleMessage(Message msg) {
// super.handleMessage(msg);
// switch (msg.what) {
// case -2:
// //加入课堂输入用户名,密码
// joinClass("", (Boolean) msg.obj);
// break;
// case -1:
// //退出
// // xdySdk.api("leaveClass", "");
// break;
// case 0:
// parseJoinClass((String) msg.obj,true);
// break;
// case 7:
// break;
// case 8:
// btnVideoPlayPubsherVideo.setEnabled(true);
// btn_videoPlay_publisherAudio.setEnabled(true);
// break;
//
// }
// }
// };
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //屏幕常亮
// setContentView(R.layout.activity_video_publisher);
// ButterKnife.bind(this);
// btn_videoPlay_publisherAudio.setVisibility(View.GONE);
//// setTablayout();
// xdySdk=XdySdk.getXdyInstance();
// xdySdk.add(this);
// init();
// XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+"");
// xdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() {
// @Override
// public void onXdyAsyncMessageReceiver(String type, String response) {
//
// switch (type) {
// case "class_init_success":
// ToastUtil.showToastshort("初始化课堂成功", VideoPublisherActivity.this);
// Message message = Message.obtain();
// message.obj = response;
// message.what = 0;
// handler.sendMessage(message);
// break;
// case "class_join_success":
// //加入课堂成功
// UIUtils.closeDialog(mLoginDialog);
// ToastUtil.showToastshort("加入课堂成功", VideoPublisherActivity.this);
// //只有加入课堂成功才可以点击推流的按钮
// handler.sendEmptyMessage(8);
// break;
// case "video_stop":
//// handler.sendEmptyMessage(7);
// break;
// case "audio_stop":
//
// break;
// }
// XdyLogUtil.e(TAG,"type:"+type+" response:"+response);
// }
// });
// }
//
// public void init() {
// initClass = getIntent().getStringExtra("init");
// xdySdk.api("init", initClass);
//
// }
//private LoginDialog mLoginDialog;
// //判断解析是否有密码
// public void parseJoinClass(String rsponse,boolean isShowPwd){
// InitClassSuccessEntity initClassSuccessEntity=JsonUtil.parseJsonToBean(rsponse,InitClassSuccessEntity.class);
// if(initClassSuccessEntity!=null) {
// if (initClassSuccessEntity.isPasswordRequired()) {
// isShowPwd=true;
// } else {
// isShowPwd=false;
// userpwd = "123321";
// }
// }
//
// if (mLoginDialog == null) {
// mLoginDialog = new LoginDialog(this, isShowPwd, null);
// mLoginDialog.show();
// mLoginDialog.setCanceledOnTouchOutside(false);
// final boolean finalIsShowPwd = isShowPwd;
// mLoginDialog.setBtnClick(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// String[] nameAndPwd = mLoginDialog.getNameAndPwd();
// joinClass(nameAndPwd[0], nameAndPwd[1], finalIsShowPwd);
// }
// });
// }else if (mLoginDialog != null) {
// UIUtils.closeDialog(mLoginDialog);
// }
// }
// //加入课堂
// public void joinClass(String username,String userpwd,boolean isShowPwd) {
// JoinClass joinClass=new JoinClass();
// joinClass.setHasCamera(false);
// joinClass.setHasMicrophone(false);
// joinClass.setUserName(username);
// if(!isShowPwd){
// joinClass.setPassword("123321");
// }else{
// joinClass.setPassword(userpwd);
// }
// String temp=new Gson().toJson(joinClass);
// String jsonParmp = XdyStringUtils.stringToJson(temp, true);
// XdyLogUtil.e("加入课堂", jsonParmp);
// xdySdk.api("joinClass", jsonParmp);
// }
//
// //加入课堂
// public void joinClass(String rsponse,boolean isShowPwd) {
//
//// String temp = "{\n" +
//// " \"userName\":\"base\",\n" +
//// " \"password\":\"123321\",\n" +
//// " \"hasCamera\":false,\n" +
//// " \"hasMicrophone\":false}";
// JoinClass joinClass=new JoinClass();
// joinClass.setHasCamera(false);
// joinClass.setHasMicrophone(false);
// joinClass.setUserName(username);
// if(!isShowPwd){
// joinClass.setPassword("123321");
// }else{
// joinClass.setPassword(userpwd);
// }
// String temp=new Gson().toJson(joinClass);
// String jsonParmp = XdyStringUtils.stringToJson(temp, true);
// XdyLogUtil.e("加入课堂", jsonParmp);
// xdySdk.api("joinClass", jsonParmp);
// }
//
//
//
// public void sendMeg() {
package
com
.
mang
.
xdy
.
demo
.
activity
;
import
android.app.AlertDialog
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.media.Image
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.support.design.widget.TabLayout
;
import
android.support.v4.view.ViewPager
;
import
android.support.v7.app.AppCompatActivity
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.SurfaceView
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.eventhandle.SmartEventCallback
;
import
com.google.gson.Gson
;
import
com.mang.xdy.common.Constants
;
import
com.mang.xdy.core.XdySdk
;
import
com.mang.xdy.demo.R
;
import
com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter
;
import
com.mang.xdy.demo.bean.AudioPlayBean
;
import
com.mang.xdy.demo.bean.ChatBean
;
import
com.mang.xdy.demo.bean.DocEntity
;
import
com.mang.xdy.demo.bean.ErrorEntity
;
import
com.mang.xdy.demo.bean.InitClassSuccessEntity
;
import
com.mang.xdy.demo.bean.JoinClass
;
import
com.mang.xdy.demo.bean.LiveBean
;
import
com.mang.xdy.demo.bean.PublisherEntity
;
import
com.mang.xdy.demo.bean.PublisherVideoExitBean
;
import
com.mang.xdy.demo.bean.PublisherVideoReturnBean
;
import
com.mang.xdy.demo.bean.VideoPlayBean
;
import
com.mang.xdy.demo.utils.JsonUtil
;
import
com.mang.xdy.demo.utils.ToastUtil
;
import
com.mang.xdy.demo.widget.dialog.LoginDialog
;
import
com.mang.xdy.listener.ObserverListener
;
import
com.mang.xdy.utils.UIUtils
;
import
com.mang.xdy.utils.XdyLogUtil
;
import
com.mang.xdy.utils.XdyStringUtils
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.OnClick
;
public
class
VideoPublisherActivity
extends
AppCompatActivity
implements
ObserverListener
{
private
final
static
String
TAG
=
"VideoPlayActivity"
;
@BindView
(
R
.
id
.
btn_videoPlay_pubsherVideo
)
Button
btnVideoPlayPubsherVideo
;
@BindView
(
R
.
id
.
btn_videoPlay_chat
)
Button
btnVideoPlayChat
;
@BindView
(
R
.
id
.
tv_videoPlay_url
)
TextView
tv_videoPlay_url
;
@BindView
(
R
.
id
.
surfaceview_pubisherVideo
)
SurfaceView
surfaceview_pubisherVideo
;
@BindView
(
R
.
id
.
btn_videoPlay_publisherAudio
)
Button
btn_videoPlay_publisherAudio
;
// @BindView(R.id.img_playVideo_novideo)
// ImageView img_playVideo_novideo;
private
String
username
=
""
;
private
String
userpwd
=
""
;
private
PersonDialog
personDialog
;
private
SimpleFragmentPagerAdapter
pagerAdapter
;
private
XdySdk
xdySdk
;
private
ViewPager
viewPager
;
//默认推送视频
private
boolean
isPusherAudio
=
false
;
/*默认是可以退出的,如果进行推流则需要主动退出*/
private
boolean
isAbleback
=
false
;
private
TabLayout
tabLayout
;
@BindView
(
R
.
id
.
surfaceview_playVideo
)
SurfaceView
surfaceviewPlayVideo
;
@BindView
(
R
.
id
.
btn_videoPlay_stop
)
Button
btn_videoPlay_stop
;
private
String
initClass
=
""
;
private
String
publisherSuccess
=
""
;
/*视频成功返回值*/
private
PublisherVideoReturnBean
publisherVideoReturnBean
;
private
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
-
2
:
//加入课堂输入用户名,密码
joinClass
(
""
,
(
Boolean
)
msg
.
obj
);
break
;
case
-
1
:
//退出
// xdySdk.api("leaveClass", "");
break
;
case
0
:
parseJoinClass
((
String
)
msg
.
obj
,
true
);
break
;
case
7
:
break
;
case
8
:
btnVideoPlayPubsherVideo
.
setEnabled
(
true
);
btn_videoPlay_publisherAudio
.
setEnabled
(
true
);
break
;
}
}
};
@Override
protected
void
onCreate
(
final
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
//屏幕常亮
setContentView
(
R
.
layout
.
activity_video_publisher
);
ButterKnife
.
bind
(
this
);
btn_videoPlay_publisherAudio
.
setVisibility
(
View
.
GONE
);
// setTablayout();
xdySdk
=
XdySdk
.
getXdyInstance
();
xdySdk
.
add
(
this
);
init
();
XdyLogUtil
.
e
(
TAG
,
"当前线程 main:"
+
android
.
os
.
Process
.
myPid
()+
"线程:"
+
Thread
.
currentThread
().
getId
()+
""
);
xdySdk
.
setOnXdyAsyncMessageLitener
(
new
XdySdk
.
OnXdyAsyncMessageLitener
()
{
@Override
public
void
onXdyAsyncMessageReceiver
(
String
type
,
String
response
)
{
switch
(
type
)
{
case
"class_init_success"
:
ToastUtil
.
showToastshort
(
"初始化课堂成功"
,
VideoPublisherActivity
.
this
);
Message
message
=
Message
.
obtain
();
message
.
obj
=
response
;
message
.
what
=
0
;
handler
.
sendMessage
(
message
);
break
;
case
"class_join_success"
:
//加入课堂成功
UIUtils
.
closeDialog
(
mLoginDialog
);
ToastUtil
.
showToastshort
(
"加入课堂成功"
,
VideoPublisherActivity
.
this
);
//只有加入课堂成功才可以点击推流的按钮
handler
.
sendEmptyMessage
(
8
);
break
;
case
"video_stop"
:
// handler.sendEmptyMessage(7);
break
;
case
"audio_stop"
:
break
;
}
XdyLogUtil
.
e
(
TAG
,
"type:"
+
type
+
" response:"
+
response
);
}
});
}
public
void
init
()
{
initClass
=
getIntent
().
getStringExtra
(
"init"
);
xdySdk
.
api
(
"init"
,
initClass
);
}
private
LoginDialog
mLoginDialog
;
//判断解析是否有密码
public
void
parseJoinClass
(
String
rsponse
,
boolean
isShowPwd
){
InitClassSuccessEntity
initClassSuccessEntity
=
JsonUtil
.
parseJsonToBean
(
rsponse
,
InitClassSuccessEntity
.
class
);
if
(
initClassSuccessEntity
!=
null
)
{
if
(
initClassSuccessEntity
.
isPasswordRequired
())
{
isShowPwd
=
true
;
}
else
{
isShowPwd
=
false
;
userpwd
=
"123321"
;
}
}
if
(
mLoginDialog
==
null
)
{
mLoginDialog
=
new
LoginDialog
(
this
,
isShowPwd
,
null
);
mLoginDialog
.
show
();
mLoginDialog
.
setCanceledOnTouchOutside
(
false
);
final
boolean
finalIsShowPwd
=
isShowPwd
;
mLoginDialog
.
setBtnClick
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
[]
nameAndPwd
=
mLoginDialog
.
getNameAndPwd
();
joinClass
(
nameAndPwd
[
0
],
nameAndPwd
[
1
],
finalIsShowPwd
);
}
});
}
else
if
(
mLoginDialog
!=
null
)
{
UIUtils
.
closeDialog
(
mLoginDialog
);
}
}
//加入课堂
public
void
joinClass
(
String
username
,
String
userpwd
,
boolean
isShowPwd
)
{
JoinClass
joinClass
=
new
JoinClass
();
joinClass
.
setHasCamera
(
false
);
joinClass
.
setHasMicrophone
(
false
);
joinClass
.
setUserName
(
username
);
if
(!
isShowPwd
){
joinClass
.
setPassword
(
"123321"
);
}
else
{
joinClass
.
setPassword
(
userpwd
);
}
String
temp
=
new
Gson
().
toJson
(
joinClass
);
String
jsonParmp
=
XdyStringUtils
.
stringToJson
(
temp
,
true
);
XdyLogUtil
.
e
(
"加入课堂"
,
jsonParmp
);
xdySdk
.
api
(
"joinClass"
,
jsonParmp
);
}
//加入课堂
public
void
joinClass
(
String
rsponse
,
boolean
isShowPwd
)
{
// String temp = "{\n" +
// " \"message\": \"固定发送测试 hello\",\n" +
// " \"to\": 0\n" +
// "}";
// String jsonParmp = XdyStringUtils.stringToJson(temp, true);
// XdyLogUtil.e(TAG, "聊天" + jsonParmp);
// xdySdk.api("sendChatMsg", jsonParmp);
//
// }
//
// /**
// * 获取封装的推流地址
// */
// public void publisherVideoText(){
// xdySdk.api("publishVideo", "", surfaceview_pubisherVideo, VideoPublisherActivity.this);
//// xdySdk.api(Constants.PUBLISH_AUDIO, "", surfaceview_pubisherVideo, VideoPublisherActivity.this);
//
// }
//
// @Override
// protected void onPause() {
// super.onPause();
//// xdySdk.onPublisherPause();
// }
//
// @Override
// protected void onResume() {
// super.onResume();
//// xdySdk.onPublisherResume();
// }
//
// @Override
// protected void onDestroy() {
// xdySdk.onPublisherStop();
// super.onDestroy();
// }
//
// @OnClick({R.id.btn_videoPlay_chat, R.id.btn_videoPlay_pubsherVideo,R.id.btn_videoPlay_publisherAudio,R.id.btn_videoPlay_stop})
// public void onViewClicked(View view) {
// switch (view.getId()) {
// case R.id.btn_videoPlay_chat:
// handler.sendEmptyMessage(4);
// break;
// case R.id.btn_videoPlay_pubsherVideo:
//// getPublish();
// publisherVideoText();
//// publisherAudioText();
// ToastUtil.showToastshort("推送视频",VideoPublisherActivity.this);
// btnVideoPlayPubsherVideo.setClickable(false);
//
// break;
// case R.id.btn_videoPlay_stop:
// ToastUtil.showToastshort("正在退出,请稍等",this);
// xdySdk.api("unPublishVideo","");
//// finish();
// break;
// }
// }
//
// @Override
// public void observerUpData(final String type, final String parameter) {
// handler.post(new Runnable() {
// @Override
// public void run() {
// handError(type,parameter);
// }
// });
// }
// public void handError(String errorId, String errorMsg) {
// ErrorEntity errorEntity = JsonUtil.parseJsonToBean(errorMsg, ErrorEntity.class);
// if (errorEntity == null) {
// return;
// }
// switch (errorEntity.getCode() + "") {
// case "100":
// case "101":
// case "102":
// case "103":
// case "104":
// case "105":
// case "106":
// case "107":
// case "200":
// case "201":
// case "202":
// case "203":
// case "204":
// case "205":
// case "206":
// case "207":
// case "208":
// ToastUtil.showToastshort(errorEntity.getReson(), this);
// exit();
// break;
// case "300":
// case "301":
// break;
// case "10000":
// ToastUtil.showToastshort(errorEntity.getReson(), this);
// break;
// case "10001":
// ToastUtil.showToastshort(errorEntity.getReson(), this);
// break;
// case "20000":
// isDefaultExit=false;
// showErrorDialog();
// ToastUtil.showToastshort(errorEntity.getReson(), this);
// break;
// }
//
//
// }
//
// class EventHande implements SmartEventCallback {
// @Override
// public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) {
// switch (code) {
// case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED:
// Log.i(TAG, "开始。。");
// break;
// case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING:
// Log.i(TAG, "连接中。。");
// break;
// case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED:
// Log.i(TAG, "连接失败。。");
// break;
// case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED:
// Log.i(TAG, "连接成功。。");
//// PublisherEntity publisherEntity=new PublisherEntity();
//// if(TextUtils.isEmpty(publisherSuccess)) {
//// publisherEntity.setPublishUrl(publisherSuccess);
//// XdySdk.setAsyncApi("publishVideo", new Gson().toJson(publisherEntity));
//// }
// //TODO
// break;
// case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED:
// Log.i(TAG, "连接断开。。");
// break;
// case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP:
// Log.i(TAG, "关闭。。");
// break;
// case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO:
// Log.i(TAG, "分辨率信息: width: " + param1 + ", height: " + param2);
// break;
// case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED:
// Log.i(TAG, "收不到媒体数据,可能是url错误。。");
// }
//
// }
// }
// /*mcu断开或者网络原因为false*/
// private boolean isDefaultExit=true;
// private android.support.v7.app.AlertDialog mErrorDialog;
// public void showErrorDialog() {
//// if(isDefaultExit){
//// return;
//// }
// if (mErrorDialog != null)
// return;
//
// mErrorDialog = new android.support.v7.app.AlertDialog.Builder(this)
// .setTitle("退出")
// .setMessage("您设备的网络属于断开状态,请重新进入")
// .setPositiveButton("确认", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialogInterface, int i) {
// dialogInterface.dismiss();
// exit();
// }
// })
// .create();
// mErrorDialog.setCanceledOnTouchOutside(false);
//
// mErrorDialog.show();
//
// }
//
// /**
// * 错误情况退出
// */
// public void exit() {
//
// UIUtils.closeDialog(mLoginDialog);
//// xdySdk.onPublisherStop();
// xdySdk.remove(this);
// handler.removeCallbacksAndMessages(null);
// this.finish();
// }
// class PersonDialog extends Dialog {
// public PersonDialog(Context context) {
// this(context, false);
//
// }
//
// public PersonDialog(Context context, boolean showPwd) {
// this(context, R.style.bottom_dialog, showPwd);
// }
//
// public PersonDialog(Context context, int themeResId, boolean showPwd) {
// super(context, themeResId);
// init(context, showPwd);
// }
//
// public void init(Context context, boolean showPwd) {
// View view = View.inflate(context, R.layout.dialog_item, null);
// setContentView(view);
// initView(view,showPwd);
// setCanceledOnTouchOutside(false);
// Window window = getWindow();
// WindowManager.LayoutParams params = window.getAttributes();
// params.width = WindowManager.LayoutParams.MATCH_PARENT;
// params.height = dp2px(context, 220);
// window.setAttributes(params);
// window.setGravity(Gravity.CENTER);
// }
//
// public int dp2px(Context context, float dp) {
// return (int) Math.ceil(context.getResources().getDisplayMetrics().density * dp);
// }
// public void initView(View view, final boolean showPwd){
// final EditText edt_uername= (EditText) view.findViewById(R.id.dialog_edt_username);
// final EditText edt_userpwd= (EditText) view.findViewById(R.id.dialog_edt_userpwd);
// if(showPwd){
// edt_userpwd.setVisibility(View.VISIBLE);
// }else{
// edt_userpwd.setVisibility(View.GONE);
// }
// Button btn_enter= (Button) view.findViewById(R.id.dialog_btn_enter);
// btn_enter.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// username=edt_uername.getText().toString();
// userpwd=edt_userpwd.getText().toString();
// if(TextUtils.isEmpty(username)){
// ToastUtil.showToastshort("用户名不能为空",VideoPublisherActivity.this);
// return;
// }
// if(showPwd&&TextUtils.isEmpty(userpwd)){
// ToastUtil.showToastshort("密码不能为空",VideoPublisherActivity.this);
// return;
// " \"userName\":\"base\",\n" +
// " \"password\":\"123321\",\n" +
// " \"hasCamera\":false,\n" +
// " \"hasMicrophone\":false}";
JoinClass
joinClass
=
new
JoinClass
();
joinClass
.
setHasCamera
(
false
);
joinClass
.
setHasMicrophone
(
false
);
joinClass
.
setUserName
(
username
);
if
(!
isShowPwd
){
joinClass
.
setPassword
(
"123321"
);
}
else
{
joinClass
.
setPassword
(
userpwd
);
}
String
temp
=
new
Gson
().
toJson
(
joinClass
);
String
jsonParmp
=
XdyStringUtils
.
stringToJson
(
temp
,
true
);
XdyLogUtil
.
e
(
"加入课堂"
,
jsonParmp
);
xdySdk
.
api
(
"joinClass"
,
jsonParmp
);
}
public
void
sendMeg
()
{
String
temp
=
"{\n"
+
" \"message\": \"固定发送测试 hello\",\n"
+
" \"to\": 0\n"
+
"}"
;
String
jsonParmp
=
XdyStringUtils
.
stringToJson
(
temp
,
true
);
XdyLogUtil
.
e
(
TAG
,
"聊天"
+
jsonParmp
);
xdySdk
.
api
(
"sendChatMsg"
,
jsonParmp
);
}
/**
* 获取封装的推流地址
*/
public
void
publisherVideoText
(){
xdySdk
.
api
(
"publishVideo"
,
""
,
surfaceview_pubisherVideo
,
VideoPublisherActivity
.
this
);
// xdySdk.api(Constants.PUBLISH_AUDIO, "", surfaceview_pubisherVideo, VideoPublisherActivity.this);
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
xdySdk
.
onPublisherPause
();
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
xdySdk
.
onPublisherResume
();
}
@Override
protected
void
onDestroy
()
{
xdySdk
.
onPublisherStop
();
super
.
onDestroy
();
}
@OnClick
({
R
.
id
.
btn_videoPlay_chat
,
R
.
id
.
btn_videoPlay_pubsherVideo
,
R
.
id
.
btn_videoPlay_publisherAudio
,
R
.
id
.
btn_videoPlay_stop
})
public
void
onViewClicked
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
btn_videoPlay_chat
:
handler
.
sendEmptyMessage
(
4
);
break
;
case
R
.
id
.
btn_videoPlay_pubsherVideo
:
// getPublish();
publisherVideoText
();
// publisherAudioText();
ToastUtil
.
showToastshort
(
"推送视频"
,
VideoPublisherActivity
.
this
);
btnVideoPlayPubsherVideo
.
setClickable
(
false
);
break
;
case
R
.
id
.
btn_videoPlay_stop
:
ToastUtil
.
showToastshort
(
"正在退出,请稍等"
,
this
);
xdySdk
.
api
(
"unPublishVideo"
,
""
);
// finish();
break
;
}
}
@Override
public
void
observerUpData
(
final
String
type
,
final
String
parameter
)
{
handler
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
handError
(
type
,
parameter
);
}
});
}
public
void
handError
(
String
errorId
,
String
errorMsg
)
{
ErrorEntity
errorEntity
=
JsonUtil
.
parseJsonToBean
(
errorMsg
,
ErrorEntity
.
class
);
if
(
errorEntity
==
null
)
{
return
;
}
switch
(
errorEntity
.
getCode
()
+
""
)
{
case
"100"
:
case
"101"
:
case
"102"
:
case
"103"
:
case
"104"
:
case
"105"
:
case
"106"
:
case
"107"
:
case
"200"
:
case
"201"
:
case
"202"
:
case
"203"
:
case
"204"
:
case
"205"
:
case
"206"
:
case
"207"
:
case
"208"
:
ToastUtil
.
showToastshort
(
errorEntity
.
getReson
(),
this
);
exit
();
break
;
case
"300"
:
case
"301"
:
break
;
case
"10000"
:
ToastUtil
.
showToastshort
(
errorEntity
.
getReson
(),
this
);
break
;
case
"10001"
:
ToastUtil
.
showToastshort
(
errorEntity
.
getReson
(),
this
);
break
;
case
"20000"
:
isDefaultExit
=
false
;
showErrorDialog
();
ToastUtil
.
showToastshort
(
errorEntity
.
getReson
(),
this
);
break
;
}
}
class
EventHande
implements
SmartEventCallback
{
@Override
public
void
onCallback
(
int
code
,
long
param1
,
long
param2
,
String
param3
,
String
param4
,
Object
param5
)
{
switch
(
code
)
{
case
EVENTID
.
EVENT_DANIULIVE_ERC_PLAYER_STARTED
:
Log
.
i
(
TAG
,
"开始。。"
);
break
;
case
EVENTID
.
EVENT_DANIULIVE_ERC_PLAYER_CONNECTING
:
Log
.
i
(
TAG
,
"连接中。。"
);
break
;
case
EVENTID
.
EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED
:
Log
.
i
(
TAG
,
"连接失败。。"
);
break
;
case
EVENTID
.
EVENT_DANIULIVE_ERC_PLAYER_CONNECTED
:
Log
.
i
(
TAG
,
"连接成功。。"
);
// PublisherEntity publisherEntity=new PublisherEntity();
// if(TextUtils.isEmpty(publisherSuccess)) {
// publisherEntity.setPublishUrl(publisherSuccess);
// XdySdk.setAsyncApi("publishVideo", new Gson().toJson(publisherEntity));
// }
// dismiss();
// Message message=Message.obtain();
// message.what=-2;
// message.obj=showPwd;
// handler.sendMessage(message);
// }
// });
//TODO
break
;
case
EVENTID
.
EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED
:
Log
.
i
(
TAG
,
"连接断开。。"
);
break
;
case
EVENTID
.
EVENT_DANIULIVE_ERC_PLAYER_STOP
:
Log
.
i
(
TAG
,
"关闭。。"
);
break
;
case
EVENTID
.
EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO
:
Log
.
i
(
TAG
,
"分辨率信息: width: "
+
param1
+
", height: "
+
param2
);
break
;
case
EVENTID
.
EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED
:
Log
.
i
(
TAG
,
"收不到媒体数据,可能是url错误。。"
);
}
}
}
/*mcu断开或者网络原因为false*/
private
boolean
isDefaultExit
=
true
;
private
android
.
support
.
v7
.
app
.
AlertDialog
mErrorDialog
;
public
void
showErrorDialog
()
{
// if(isDefaultExit){
// return;
// }
// }
//
//}
if
(
mErrorDialog
!=
null
)
return
;
mErrorDialog
=
new
android
.
support
.
v7
.
app
.
AlertDialog
.
Builder
(
this
)
.
setTitle
(
"退出"
)
.
setMessage
(
"您设备的网络属于断开状态,请重新进入"
)
.
setPositiveButton
(
"确认"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
dialogInterface
.
dismiss
();
exit
();
}
})
.
create
();
mErrorDialog
.
setCanceledOnTouchOutside
(
false
);
mErrorDialog
.
show
();
}
/**
* 错误情况退出
*/
public
void
exit
()
{
UIUtils
.
closeDialog
(
mLoginDialog
);
// xdySdk.onPublisherStop();
xdySdk
.
remove
(
this
);
handler
.
removeCallbacksAndMessages
(
null
);
this
.
finish
();
}
class
PersonDialog
extends
Dialog
{
public
PersonDialog
(
Context
context
)
{
this
(
context
,
false
);
}
public
PersonDialog
(
Context
context
,
boolean
showPwd
)
{
this
(
context
,
R
.
style
.
bottom_dialog
,
showPwd
);
}
public
PersonDialog
(
Context
context
,
int
themeResId
,
boolean
showPwd
)
{
super
(
context
,
themeResId
);
init
(
context
,
showPwd
);
}
public
void
init
(
Context
context
,
boolean
showPwd
)
{
View
view
=
View
.
inflate
(
context
,
R
.
layout
.
dialog_item
,
null
);
setContentView
(
view
);
initView
(
view
,
showPwd
);
setCanceledOnTouchOutside
(
false
);
Window
window
=
getWindow
();
WindowManager
.
LayoutParams
params
=
window
.
getAttributes
();
params
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
;
params
.
height
=
dp2px
(
context
,
220
);
window
.
setAttributes
(
params
);
window
.
setGravity
(
Gravity
.
CENTER
);
}
public
int
dp2px
(
Context
context
,
float
dp
)
{
return
(
int
)
Math
.
ceil
(
context
.
getResources
().
getDisplayMetrics
().
density
*
dp
);
}
public
void
initView
(
View
view
,
final
boolean
showPwd
){
final
EditText
edt_uername
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
dialog_edt_username
);
final
EditText
edt_userpwd
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
dialog_edt_userpwd
);
if
(
showPwd
){
edt_userpwd
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
edt_userpwd
.
setVisibility
(
View
.
GONE
);
}
Button
btn_enter
=
(
Button
)
view
.
findViewById
(
R
.
id
.
dialog_btn_enter
);
btn_enter
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
username
=
edt_uername
.
getText
().
toString
();
userpwd
=
edt_userpwd
.
getText
().
toString
();
if
(
TextUtils
.
isEmpty
(
username
)){
ToastUtil
.
showToastshort
(
"用户名不能为空"
,
VideoPublisherActivity
.
this
);
return
;
}
if
(
showPwd
&&
TextUtils
.
isEmpty
(
userpwd
)){
ToastUtil
.
showToastshort
(
"密码不能为空"
,
VideoPublisherActivity
.
this
);
return
;
}
dismiss
();
Message
message
=
Message
.
obtain
();
message
.
what
=-
2
;
message
.
obj
=
showPwd
;
handler
.
sendMessage
(
message
);
}
});
}
}
}
...
...
MyApplication/XdyDemo/src/main/java/com/mang/xdy/demo/widget/view/AutoAdaptHeaderViewGroup.java
0 → 100644
查看文件 @
739771b
package
com
.
mang
.
xdy
.
demo
.
widget
.
view
;
import
android.content.Context
;
import
android.os.Build
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.RelativeLayout
;
import
com.mang.xdy.demo.utils.DisplayUtil
;
public
class
AutoAdaptHeaderViewGroup
extends
RelativeLayout
{
private
int
statusBarHeight
;
public
AutoAdaptHeaderViewGroup
(
Context
context
)
{
this
(
context
,
null
);
}
public
AutoAdaptHeaderViewGroup
(
Context
context
,
AttributeSet
attrs
)
{
this
(
context
,
attrs
,
0
);
}
public
AutoAdaptHeaderViewGroup
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
statusBarHeight
=
DisplayUtil
.
getStatusBarHeight
(
getContext
());
}
private
LayoutParams
makeLayoutParams
(
View
view
)
{
ViewGroup
.
LayoutParams
lpOld
=
view
.
getLayoutParams
();
LayoutParams
lp
=
null
;
if
(
lpOld
==
null
)
{
lp
=
new
LayoutParams
(-
2
,
-
1
);
}
else
{
lp
=
new
LayoutParams
(
lpOld
.
width
,
lpOld
.
height
);
}
return
lp
;
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
//设置headerbar高度
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
//加上状态栏的高度
int
paddingBottom
=
getPaddingBottom
();
int
paddingRight
=
getPaddingRight
();
int
paddingLeft
=
getPaddingLeft
();
setPadding
(
paddingLeft
,
statusBarHeight
,
paddingRight
,
paddingBottom
);
}
}
}
...
...
MyApplication/XdyDemo/src/main/res/mipmap-xxhdpi/camerap_normal2x.png
0 → 100644
查看文件 @
739771b
1.7 KB
MyApplication/XdyDemo/src/main/res/mipmap-xxhdpi/hangup_normal2x.png
0 → 100644
查看文件 @
739771b
3.0 KB
请
注册
或
登录
后发表评论