发布网友 发布时间:2023-04-27 02:40
共1个回答
热心网友 时间:2023-10-21 13:14
*Android视频聊天
*1、初始化SDK2、连接服务器、3、用户登录;4、进入房间;5、打开本地视频;6、请求对方视频
publicclassextendsActivityimplements
{
privateanychat;//核心SDK
privateSurfaceView;//对方视频
privateSurfaceView;//本地视频
private;
privateboolean=false;//本地视频是否已打开
privateboolean=false;//对方视频是否已打开
privateTimerTaskmTimerTask;//定时器
privateTimermTimer=newTimer(true);
privateHandlerhandler;//用Handler来不间断刷新即时视频
privateList
privateintuserid;//用户ID
@Override
publicvoidonCreate(Bundle)
{
super.onCreate();
(R.layout.activity_video_chat);
=(SurfaceView)(R.id.surface_remote);
=(SurfaceView)(R.id.surface_local);
configEntity=ConfigService.LoadConfig(this);//加载视频通话设置
loginSystem();//初始化SDK连接服务器
mTimerTask=newTimerTask(){
publicvoidrun(){
Messagemesasge=newMessage();
handler.sendMessage(mesasge);
}
};
mTimer.schele(mTimerTask,1000,100);
handler=newHandler(){
@Override
publicvoidhandleMessage(Messagemsg){
VideoChat();//不间断显示即时视频通话画面
super.handleMessage(msg);
}
};
}