initSDKWithAppKey login logout startInstantMeeting startMeetingWithParams joinMeetingWithParams addInMeetingServiceListener removeInMeetingServiceListener getCurrentMeetingNumber getCurrentMeetingID isCurrentMeetingHost disableChatUI getInMeetingUserList getMyUserID getMyUserInfo getUserInfoById getInMeetingUserCount changeName getCurrentMeetingTopic leaveCurrentMeeting
该插件封装了瞩目的sdk
##iOS屏幕共享
###iOS Broadcast Upload Extension制作
####工程里添加target
选择Broadcast Upload Extension类型,bundleid最好设置为主工程id+ExtensionReplay(例:主工程bundleid:xxx.xxx.xxx,新添加target的bundleid:xxx.xxx.xxx.ExtensionReplay),另外,工程中会自动创建一个SampleHandler类。
注意:添加新的target的时候,xcode会自动添加一个和新target对应的ui的target,可以直接将此ui target删除,对应工程目录里的该ui的文件也删除即可,新添加的target设置ios最低支持系统为ios11(主工程ios最低支持系统不变)。
####导入相关库
在新添加的target里导入ZhumuSDK.framework、 MobileRTCScreenShare.framework、ReplayKit.framework。
● ZhumuSDKScreenShareService现在要求除了ReplayKit之外,还需要向扩展目标添加以下框架:
CoreGraphics.framework CoreVideo.framework CoreMedia.framework VideoToolbox.framework ZhumuSDKScreenShareService现在还要求SampleHandler.m修改成SampleHandler.mm. 如果改用swift,则必须在扩展目标的设置中“ “Other linker flags””添加 -lc++
####关联App Group
进入苹果开发者后台,创建一个新的App Group,将主工程bundleid和新添加的target的bundleid添加到该App Group下。回到主工程,在主工程target和新添加的target里打开App Groups的开关,然后勾选对应刚才添加的group。(或直接在工程里的capabilities里直接打开App Groups的开关,然后点击里面的“+”号进行添加,然后勾选新添加的group)。
###代码说明
####SampleHandler文件代码
#import "SampleHandler.h"
#import <ZhumuSDK/ZhumuScreenShareService.h>
@interface SampleHandler () <ZhumuShareScreenShareServiceDelegate>
@property (strong, nonatomic) ZhumuScreenShareService * screenShareService;
@end
@implementation SampleHandler
- (instancetype)init
{
self = [super init];
if (self)
{
ZhumuScreenShareService * service = [[ZhumuScreenShareService alloc]init];
self.screenShareService = service;
self.screenShareService.appGroup = @"group的名字";
self.screenShareService.delegate = self;
}
return self;
}
- (void)broadcastStartedWithSetupInfo:(NSDictionary<NSString *,NSObject *> *)setupInfo {
// User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.
[self.screenShareService broadcastStartedWithSetupInfo:setupInfo];
}
- (void)broadcastPaused {
// User has requested to pause the broadcast. Samples will stop being delivered.
[self.screenShareService broadcastPaused];
}
- (void)broadcastResumed {
// User has requested to resume the broadcast. Samples delivery will resume.
[self.screenShareService broadcastResumed];
}
- (void)broadcastFinished {
// User has requested to finish the broadcast.
[self.screenShareService broadcastFinished];
}
- (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType {
[self.screenShareService processSampleBuffer:sampleBuffer withType:sampleBufferType];
switch (sampleBufferType) {
case RPSampleBufferTypeVideo:
// Handle video sample buffer
break;
case RPSampleBufferTypeAudioApp:
// Handle audio sample buffer for app audio
break;
case RPSampleBufferTypeAudioMic:
// Handle audio sample buffer for mic audio
break;
default:
break;
}
}
- (void)dealloc
{
self.screenShareService = nil;
}
- (void)ZhumuShareScreenShareServiceFinishBroadcastWithError:(NSError *)error {
[self finishBroadcastWithError:error];
}
@end
####自定义插件包
制作方法如下:
下载 zhumuAppendix 插件 zip 包并解压,把制作的Broadcast Upload Extension放入plugins目录下,然后重新压缩为 zip 包文件上传自定义插件,应用打包时勾选该插件。
####主工程配置groupId
创建 entitlements 文件,修改内容后命名为UZApp.entitlements文件,然后将文件放置在widget网页包的res目录下,应用打包时会将里面的内容添加到编译工程里面的UZApp.entitlements中,配置详情参考论坛文档示例如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.suirui.appGroups</string>
</array>
</dict>
</plist>
获取版本信息
getSdkVersion(callback(ret))
ret:
{
version:'' //字符串类型,sdk版本号
}
var zhumu = api.require('zhumu');
zhumu.getSdkVersion(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
使用appKey、appSecret初始化
initSDKWithAppKey({params}, callback(ret))
domain:
appKey:
appSecret:
enableLog:
logSize:
appGroupId:
ret:
{
errorCode: 0 //数字类型,返回的errorCode;iOS端详见附件iOS端errorCode说明
}
var zhumu = api.require('zhumu');
zhumu.initSDKWithAppKey({
domain:'',
appKey:'',
appSecret:''
}, function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
登录
login({params}, callback(ret))
userName:
password:
ret:
{
eventType: "login" // 字符串类型;事件类型
retCode:0 // 数字类型;仅登录及登出会回调,0为登陆、登出成功
}
var zhumu = api.require('zhumu');
zhumu.login({
userName:'',
password:''
}, function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
登出
logout()
var zhumu = api.require('zhumu');
zhumu.logout();
iOS系统,Android系统
可提供的1.0.0及更高版本
开始即时会议,iOS不支持
startInstantMeeting({params}, callback(ret))
autoConnectVoIP:
turnOffVideo:
muteMicrophone:
ret:
{
meetingStatus: 0 //数字类型,会议状态;iOS端详见附件iOS端errorCode说明
}
var zhumu = api.require('zhumu');
zhumu.startInstantMeeting({
autoConnectVoIP:true,
}, function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
Android系统
可提供的1.0.0及更高版本
开始会议
startMeetingWithParams({params}, callback(ret))
meetingNo:
noAudio:
noVideo:
ret:
{
code: 0 //数字类型;;iOS端详见附件iOS端errorCode说明
}
var zhumu = api.require('zhumu');
zhumu.startMeetingWithParams({
meetingNo:'123456',
}, function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
加入会议
joinMeetingWithParams({params}, callback(ret))
meetingNo:
noAudio:
noVideo:
noInvite:
noDisconnectAudio:
displayName:
password:
ret:
{
code: 0 //数字类型;
}
var zhumu = api.require('zhumu');
zhumu.joinMeetingWithParams({
meetingNo:'123456',
}, function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
会议中的事件
addInMeetingServiceListener(callback(ret))
ret:
{
eventType:'', // 字符串类型;事件类型
userId:100000, // 数字类型;用户id
userIds:[], // 数组;eventType 为 onMeetingUserJoin & onMeetingUserLeave 时返回
errCode:-1, // 数字类型;错误码 eventType 为 onMeetingFail时返回
state:0, // 数字类型;会议状态 eventType 为 onMeetingStateChange时返回
//取值如下:
//0:No meeting is running
//1:Connect to the meeting server status
//2:Waiting for the host to start the meeting
//3:Meeting is ready, in meeting status
//4:Disconnect the meeting server, leave meeting status
//5:Reconnecting meeting server status
//6:Failed to connect the meeting server
//7:Meeting ends
//8:Unknown status
//9:Meeting is locked to prevent the further participants from joining the meeting
//10:Participants who join the meeting before the start are in the waiting room
//11:Upgrade the attendees to panelist in webinar
//12:Downgrade the attendees from the panelist
//13:Join the breakout room
//14:Leave the breakout room
//15:Waiting for the additional secret key
status:0, // 数字类型;eventType 为 onMeetingStatusChanged时返回
// 0 MEETING_STATUS_IDLE,
// 1 MEETING_STATUS_CONNECTING,
// 2 MEETING_STATUS_WAITINGFORHOST,
// 3 MEETING_STATUS_INMEETING,
// 4 MEETING_STATUS_DISCONNECTING,
// 5 MEETING_STATUS_RECONNECTING,
// 6 MEETING_STATUS_FAILED,
// 7 MEETING_STATUS_IN_WAITING_ROOM,
// 8 MEETING_STATUS_WEBINAR_PROMOTE,
// 9 MEETING_STATUS_WEBINAR_DEPROMOTE,
// 10 MEETING_STATUS_UNKNOWN;
reason:0, // 数字类型;会议结束原因 eventType 为 onMeetingLeaveComplete时返回,仅iOS支持
//取值如下:
//0:Leave meeting by myself
//1:Remove from meeting by host
//2:meeting end by host
//3:Join meeting before host timeout
//4:free meeting end by timeout
//6:Host end meeting for another meeting
//7:Meeting end by connection broken, such as network issue
//8:Meeting end by unknown reason
}
var zhumu = api.require('zhumu');
zhumu.addInMeetingServiceListener(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
移除会议中的事件
removeInMeetingServiceListener()
var zhumu = api.require('zhumu');
zhumu.removeInMeetingServiceListener();
iOS系统,Android系统
可提供的1.0.0及更高版本
当前会议号
getCurrentMeetingNumber(callback(ret))
ret:
{
meetingNo:0, //数字类型
}
var zhumu = api.require('zhumu');
zhumu.getCurrentMeetingNumber(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
当前会议ID
getCurrentMeetingID(callback(ret))
ret:
{
meetingID:''//字符串类型
}
var zhumu = api.require('zhumu');
zhumu.getCurrentMeetingID(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
是否为当前会议主持
isCurrentMeetingHost(callback(ret))
ret:
{
isMeetingHost: true
}
var zhumu = api.require('zhumu');
zhumu.isCurrentMeetingHost(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
可提供的1.0.0及更高版本
此方法设置是否隐藏UI中的"聊天"按钮
disableChatUI()
enable:
var zhumu = api.require('zhumu');
zhumu.disableChatUI(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
会议成员列表
getInMeetingUserList(callback(ret))
ret:
{
users:[
12334,
34343,
33338
]
}
var zhumu = api.require('zhumu');
zhumu.getInMeetingUserList(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
获取自己的UserId
getMyUserID(callback(ret))
ret:
{
userId:12345
}
var zhumu = api.require('zhumu');
zhumu.getMyUserID(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
获取自己用户信息
getMyUserInfo(callback(ret))
ret:
{
userId:12345, // 数字类型;用户id
userName:'', // 字符串;用户名称
avater:'' // 字符串;头像地址
}
var zhumu = api.require('zhumu');
zhumu.getMyUserInfo(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
通过id获取用户信息
getUserInfoById(callback(ret))
userId:
ret:
{
userId:12345, // 数字类型;用户id
userName:'', // 字符串;用户名称
avater:'' // 字符串;头像地址
}
var zhumu = api.require('zhumu');
zhumu.getUserInfoById({
userId:0
},function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
获取参加会议的人数
getInMeetingUserCount(callback(ret))
ret:
{
count:5, // 数字类型;用户数
}
var zhumu = api.require('zhumu');
zhumu.getInMeetingUserCount(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
更改用户名
changeName({params})
name:
var zhumu = api.require('zhumu');
zhumu.changeName({
name:''
});
iOS系统,Android系统
可提供的1.0.0及更高版本
获取会议主题
getCurrentMeetingTopic(callback(ret))
ret:
{
topic: "" //字符串,会议主题
}
var zhumu = api.require('zhumu');
zhumu.getCurrentMeetingTopic(function(ret, err) {
if (ret) {
api.alert({
msg: JSON.stringify(ret)
})
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS系统,Android系统
可提供的1.0.0及更高版本
离开或结束当前会议
leaveCurrentMeeting({params})
finish:
var zhumu = api.require('zhumu');
zhumu.leaveCurrentMeeting({
finish:true
});
iOS系统,Android系统
可提供的1.0.0及更高版本
{
///start/join meeting successfully
ZhumuSDKMeetError_Success = 0,
///network issue, please check network connection
ZhumuSDKMeetError_NetworkError = 1,
///failed to reconnect meeting
ZhumuSDKMeetError_ReconnectError = 2,
///mmr issue, please check mmr configuration
ZhumuSDKMeetError_MMRError = 3,
///meeting password incorrect
ZhumuSDKMeetError_PasswordError = 4,
///failed to create video and audio data connection with mmr
ZhumuSDKMeetError_SessionError = 5,
///the meeting is over
ZhumuSDKMeetError_MeetingOver = 6,
///the meeting does not start
ZhumuSDKMeetError_MeetingNotStart = 7,
///the meeting does not exist
ZhumuSDKMeetError_MeetingNotExist = 8,
///the meeting has reached a maximum of participants
ZhumuSDKMeetError_MeetingUserFull = 9,
///the meeting version is incompatible
ZhumuSDKMeetError_MeetingClientIncompatible = 10,
///there does not exist valid mmr
ZhumuSDKMeetError_NoMMR = 11,
///the meeting was locked by host
ZhumuSDKMeetError_MeetingLocked = 12,
///the meeting was restricted
ZhumuSDKMeetError_MeetingRestricted = 13,
///the meeting was restricted join before host
ZhumuSDKMeetError_MeetingRestrictedJBH = 14,
///failed to send creat meeting command to web server
ZhumuSDKMeetError_CannotEmitWebRequest = 15,
///failed to start meeting with expired token
ZhumuSDKMeetError_CannotStartTokenExpire = 16,
///the user video cannot work
ZhumuSDKMeetError_VideoError = 17,
///the user audio cannot auto start
ZhumuSDKMeetError_AudioAutoStartError = 18,
///webinar has reached its maximum
ZhumuSDKMeetError_RegisterWebinarFull = 19,
///sign in to start the webinar
ZhumuSDKMeetError_RegisterWebinarHostRegister = 20,
///join the webinar from the link
ZhumuSDKMeetError_RegisterWebinarPanelistRegister = 21,
///host has denied your webinar registration
ZhumuSDKMeetError_RegisterWebinarDeniedEmail = 22,
///sign in with the specified account to join webinar
ZhumuSDKMeetError_RegisterWebinarEnforceLogin = 23,
///the certificate of ZC has been changed
ZhumuSDKMeetError_ZCCertificateChanged = 24,
///the vanity url does not exist
ZhumuSDKMeetError_VanityNotExist = 27,
///the email address has already been register in this webinar
ZhumuSDKMeetError_JoinWebinarWithSameEmail = 28,
///failed to write config file
ZhumuSDKMeetError_WriteConfigFile = 50,
///Removed By host
ZhumuSDKMeetError_RemovedByHost = 61,
///Invalid Arguments
ZhumuSDKMeetError_InvalidArguments = 150,
///Invalid User Type
ZhumuSDKMeetError_InvalidUserType,
///Already In another ongoing meeting
ZhumuSDKMeetError_InAnotherMeeting,
///The request too frequence
ZhumuSDKMeetError_TooFrequenceCall,
///Wrong usage of the api
ZhumuSDKMeetError_WrongUsage,
///Failed of the api call
ZhumuSDKMeetError_Failed,
///The virtual background error base
ZhumuSDKMeetError_VBBase = 200,
///Set image for virtual background error
ZhumuSDKMeetError_VBSetError = ZhumuSDKMeetError_VBBase,
///Virtual background image reach to max capacity
ZhumuSDKMeetError_VBMaximumNum,
///Virtual background save the image error
ZhumuSDKMeetError_VBSaveImage,
///Virtual background save the image error
ZhumuSDKMeetError_VBRemoveNone,
///Virtual background not support
ZhumuSDKMeetError_VBNoSupport,
///Virtual background GreenScreen not support, only iPad support green screen.
ZhumuSDKMeetError_VBGreenScreenNoSupport,
///Unknown error
ZhumuSDKMeetError_Unknown,
}