互联网多人语音

语音会议             

1、互联网多人语音说明

 语音会议是多人参加的基于互联网、或者基于电话或者网络和电话混合的会议。                 
1.1、接口逻辑               
调用是采取“请求回调”和“通知回调”的方式和服务端交互。在对应的sdk的方法参数中有“请求回调”方法,请求的结果直接在参数的回调方法中处理。。会议中的成员收到服务端发送过来的消息通过“通知回调”方法onReceiveVoiceMeetingMsg(ECVoiceMeetingMsg  msg)来接收并进行处理。                         
1.2、业务流程                
(1)用户A创建语音会议或者电话会议              
(2)会议创建成功之后,邀请其他成员加入会议                
(3)其他成员收到邀请,同意或拒绝加入会议
                    

2、互联网多人视频操作代码示例                         

创建语音会议

我们假设Tony要创建语音会议,其示例代码如下:                                        
  • ECMeetingManager.ECCreateMeetingParams.Builder builder = new ECMeetingManager.ECCreateMeetingParams.Builder();
  •         // 设置语音会议房间名称
  •         builder.setMeetingName(mNameEditView.getText().toString().trim())
  •         // 设置语音会议房间加入密码
  •         .setMeetingPwd(mPasswordEditView.getText().toString().trim())
  •         // 设置语音会议创建者退出是否自动解散会议
  •         .setIsAutoClose(mCloseCheckedView.isChecked())
  •         // 设置语音会议创建成功是否自动加入
  •         .setIsAutoJoin(mJoinCheckedView.isChecked())
  •         // 设置语音会议背景音模式
  •         .setVoiceMod(
  •         ECMeetingManager.ECCreateMeetingParams.ToneMode.values()[mToneTypeView.getChoiceItemPosition()])
  •         // 设置语音会议所有成员退出后是否自动删除会议
  •         .setIsAutoDelete(mDelCheckedView.isChecked());                        
  •         ECDevice.getECMeetingManager().createMultiMeetingByType(params, 
  •         ECMeetingManager.ECMeetingType.MEETING_MULTI_VOICE,
  •                 new ECMeetingManager.OnCreateOrJoinMeetingListener() {
  •                     @Override
  •                     public void onCreateOrJoinMeeting(ECError reason, String meetingNo) {
  •                         if (reason.errorCode == SdkErrorCode.REQUEST_SUCCESS) {
  •                             //创建语音会议成功
  •                         }else {
  •                             //创建语音会议失败
  •                         }                        
  •                     }
  •                 }); 
  •                 
  • 功能:创建语音会议
  • 参数:params 创建语音会议的参数对象 参考ECCreateMeetingParams对象。
  • 返回值:无

邀请成员加入会议

我们假设Tony创建语音会议成功之后,邀请John和Smith加入语音会议,其代码如下:             
                        
  • String members[]=[”John的账号”,”Smith的账号”];
  • String mMeetingNo =”会议号”;
  • Boolean isLandingCall:代表邀请的时候以手机形式或者app形式进行呼叫
  • ECDevice.getECMeetingManager().inviteMembersJoinToVoiceMeeting (mMeetingNo, members , isLandingCall,
  •                 new ECMeetingManager.OnInviteMembersJoinToVoiceMeetingListener() {
  •                     @Override
  •                     public void onInviteMembersJoinToChatroom(ECError reason, String meetingNo) {
  •                        
  •                         if(SdkErrorCode.REQUEST_SUCCESS == reason.errorCode) {
  •                             // 邀请加入会议成功                          
  •                         }
  •                         ToastUtil.showMessage("邀请加入会议失败["+ reason.errorCode + "]");
  •                     }
  •                 }); 

主动加入会议

我们假设Eric要主动加入会议,其示例代码如下:
                                        
  • String meetingNo=”会议号”;
  • String password=”会议的密码”;
  • ECDevice.getECMeetingManager().joinMeetingByType (meetingNo, password, ECMeetingManager.ECMeetingType.MEETING_MULTI_VOICE, new ECMeetingManager.OnCreateOrJoinMeetingListener() {
  •             @Override
  •             public void onCreateOrJoinMeeting(ECError reason, String meetingNo) {
  •                 if (reason.errorCode == SdkErrorCode.REQUEST_SUCCESS) {
  •                     //加入会议成功
  •                 }else {
  •                    //加入会议失败
  •                 }                
  •             }
  •         });  }                                  

通过会议类型解散语音会议

我们假设Tony要解散自己创建的一个语音会议,其示例代码如下:                                        
  • meetingNo;//想要删除的会议号
  • ECDevice.getECMeetingManager().deleteMultiMeetingByType (ECMeetingManager.ECMeetingType.MEETING_MULTI_VOICE, meetingNo,
  •                 new ECMeetingManager.OnDeleteMeetingListener() {
  •                     @Override
  •                     public void onMeetingDismiss(ECError reason, String meetingNo) {
  •                         if (reason.errorCode == SdkErrorCode.REQUEST_SUCCESS) {
  •                            //解散会议成功
  •                         }else {
  •                            //解散会议失败
  •                         }                       
  •                     }
  •                 });                                 

退出语音会议

退出会议,其示例代码如下:                                      
  • ECDevice.getECMeetingManager().exitMeeting(ECMeetingManager.ECMeetingType.MEETING_MULTI_VOICE);

  • 功能:退出会议 参数:无。                                                                  

从语音会议踢出会议成员

只有会议创建者才能踢出成员,我们假设Tony要踢出John,其示例代码如下:                                        
  • String member= “被踢出成员号”;
  • meetingNo=”会议号”;
  • boolean isMobile //当前被移除的是否是电话号码
  • ECDevice.getECMeetingManager().removeMemberFromMultiMeetingByType (ECMeetingManager.ECMeetingType.MEETING_MULTI_VOICE,
  •            meetingNo ,member , isMobile ,new ECMeetingManager.OnRemoveMemberFromMeetingListener() {
  •                         @Override
  •                         public void onRemoveMemberFromMeeting(ECError reason, String member) {
  •                           
  •                             if(SdkErrorCode.REQUEST_SUCCESS == reason.errorCode) {    
  •                                 // 移除会议成员成功                                                
  •                                         }
  •                                     }
  •                                 }
  •                                 return ;
  •                             }
  •                             ToastUtil.showMessage("移除会议成员失败[" + reason.errorCode+ "]");
  •                         }
  •                     });
  •                     
  • 功能:从语音会议移除成员
  • 参数:meetingNo 会议号
  • 返回值:无      
                                

语音会议通知消息

当对语音会议进行操作(如邀请、主动加入、退出、解散、踢出成员)时,会议室中的相关成员通过语音会议的“通知回调”接口onReceiveVoiceMeetingMsg接收相关信息,并进行处理,其代码示例如下:                                       
  • public void void onReceiveVoiceMeetingMsg(ECVoiceMeetingMsg msg){
  •  ECVoiceMeetingMsgType msgType= msg. getMsgType();
  •     if(msgType==JOIN)
  •     {
  •         Log(@"有人加入");
  •     }
  •     else if(msgType==EXIT)
  •     {
  •         Log(@"有人退出"); 
  •     }
  •     else if(msgType==DELETE)
  •     {
  •         Log(@"房间被删除退出");
  •     }
  •     else if(msgType== REMOVE_MEMBER){
  •    Log(@"有人被移除");
  •     }
  • }                    

获取语音会议列表

通过“获取语音会议列表”接口,可以获得应用下的所有语音会议列表,其示例代码如下:                                     
  • ECDevice.getECMeetingManager().listAllMultiMeetingsByType ("",ECMeetingManager.ECMeetingType.MEETING_MULTI_VOICE, 
  •                                         new ECMeetingManager.OnListAllMeetingsListener<ECMeeting>() {
  •             @Override
  •             public void onListAllMeetings(ECError reason, List<ECMeeting> list) {
  •                
  •                 if(reason.errorCode == SdkErrorCode.REQUEST_SUCCESS) {
  •                     
  •                     //查询语音会议列表成功
  •                 }else {
  •                     //查询语音会议列表失败
  •                 }
  •                 
  •             }
  •         });  }                                

查询当前语音会议成员

用户加入会议后,需要获取当前语音会议中的所有成员,其示例代码如下:                                     
  • String meetingNo=”语音会议房间号”;
  • ECDevice.getECMeetingManager().queryMeetingMembersByType (meetingNo, ECMeetingManager.ECMeetingType.MEETING_MULTI_VOICE,new ECMeetingManager.OnQueryMeetingMembersListener<ECVoiceMeetingMember>() {
  •                     @Override
  •                     public void onQueryMeetingMembers(ECError reason, List<ECVoiceMeetingMember> members) {
  •                         if (reason.errorCode == SdkErrorCode.REQUEST_SUCCESS) {
  •                            //查询成员成功
  •                         }else {
  •                   //查询成员失败
  •                 }}
  •                 });                               

设置语音会议成员禁言、禁听状态                                     

  • ECMeetingManager meetingManager = ECDevice.getECMeetingManager();
  •             if(meetingManager==null){
  •                 return;
  •             }
  •            meetingManager.setMemberSpeakListen(account, type, meetingNum, meetingType, new 
  •            ECMeetingManager.OnSetMemberSpeakListenListener() {
  •             @Override
  •             public void onSetMemberSpeakListenResult(ECError error, String meetingNum) {
  •                 
  •                 if(error.errorCode==SdkErrorCode.REQUEST_SUCCESS){
  •                     
  •                     Log.d(TAG,"设置成功");
  •                 }else {
  •                     Log.d(TAG,"设置失败");
  •                 }
  •             }
  •         });                        

分页获取语音会议列表                                          

  • /**
  •      * ECMeetingManager类
  •      * 获取会议列表时、支持分页功能
  •      * @param keywords    查询关键词
  •      * @param meetingType  查询的会议类型
  •      * @param match        分页参数
  •      * @param listener     执行结果回调
  • */
  • ECMeetingPageMatch match = new ECMeetingPageMatch();
  • match.setPage(1);
  • match.setPageSize(10);
  • ECDevice.getECMeetingManager().listPageMultiMeetingsByType("keywords", 
  •      ECMeetingManager.ECMeetingType.MEETING_MULTI_VOICE, match, 
  •           new ECMeetingManager.OnListPageMeetingsListener(){

  •     @Override
  •     public void onListAllMeetings(ECError ecError, ECMeetingPageMatchResult ecMeetingPageMatchResult,
  •                 List list)         {
  •                                  // 处理消息发送结果
  •             }
  •         });