云会议为您提供Mac端的AliMeeting UI SDK,您可以阅读本文,在本地应用程序中快速集成带有UI界面的音视频会议。

前提条件

开发环境准备。
类别说明
macOS版本macOS 10.11及以上
Xcode版本Xcode 10.3及以上

集成操作

  1. 下载AliMeeting UI SDK并解压。
    SDK文件压缩包中有AliMeetingUISDK文件。
    • AliMeetingUISDK.framework:依赖文件。
    • SDKSample:示例Demo(填写入会信息可以直接运行)。
  2. 创建新项目。
    1. 打开Xcode,单击Create a new Xcode project
    2. 新项目选择macOSApplication选择App,单击Next
    3. 输入Product Name配置项为SDKSampleInterface配置项选择XIBLanguage配置项选择Objective-C。单击Next
      创建新项目
    4. 添加SDK库和第三方依赖库。
      将解压后的AliMeetingUISDK.framework依赖文件,与main.m文件放在同级目录下。在General选项卡中添加AliMeetingUISDK.framework依赖文件。
    5. 配置Info.plist工程属性,添加音视频会议所需要的权限。
      配置的KeyValue如下所示。
      • KeyPrivacy - Microphone Usage DescriptionValueIn order for participants to see you, Alimeeting requires access to your camera.
      • KeyPrivacy - Camera Usage DescriptionValueIn order to speak to participants, Alimeeting requires access to your camera.
      • Key:在App Transport Security Settings下添加Allow Arbitrary LoadsValueYES
      权限
    6. 关闭应用的沙盒模式。
    7. 关闭应用Hardened Runtime模式。
      如果您需要使用Hardened Runtime模式。请按照下图所示配置。Hardened Runtime
  3. AppDelegate.h文件中配置引用的头文件。
    #import <Cocoa/Cocoa.h>
    #import <CoreData/CoreData.h>
    #import <AlimeetingUISDK/AMUISDKGuiConfig.h>
    #import <AlimeetingUISDK/AMUISDKMeetingConfig.h>
    #import <AlimeetingUISDK/AMUiSDKMeetingMainWindow.h>
    #import <AlimeetingUISDK/AMUISDKMeetingEventDelegate.h>
    #import <AlimeetingUISDK/AMSDKLogger.h>
    
    @interface AppDelegate : NSObject <NSApplicationDelegate, AMUISDKMeetingEventDelegate>
    @property (readonly, strong) NSPersistentContainer *persistentContainer;
    @end
  4. AppDelegate.m文件中编写主程序代码。
    1. 嵌入头文件。
      #import "AppDelegate.h"
    2. 本地日志回调。
      @interface demoLogger : NSObject  <AMSDKLoggerProtocol>
      @end
      @implementation demoLogger
      + (void)action:(nonnull NSString *)module point:(nonnull NSString *)monitorPoint params:(NSDictionary * _Nullable)params {
      }
      + (void)debug:(nonnull NSString *)tag msg:(nonnull NSString *)msg {
          NSLog(@"%@ : %@", tag, msg);
      }
      + (void)error:(nonnull NSString *)tag msg:(nonnull NSString *)msg {
          NSLog(@"%@ : %@", tag, msg);
      }
      + (void)error:(nonnull NSString *)module point:(nonnull NSString *)monitorPoint params:(NSDictionary * _Nullable)params {
      }
      + (void)event:(nonnull NSString *)module point:(nonnull NSString *)monitorPoint params:(NSDictionary * _Nullable)params {
      }
      + (void)info:(nonnull NSString *)tag msg:(nonnull NSString *)msg {
          NSLog(@"%@ : %@", tag, msg);
      }
      + (void)warn:(nonnull NSString *)tag msg:(nonnull NSString *)msg {
          NSLog(@"%@ : %@", tag, msg);
      }
      @end
    3. 添加入会代码。
      @property (strong) AMUISDKMeetingMainWindow* win;
      @end
      
      @interface AppDelegate ()
      @property (weak) IBOutlet NSWindow *window;
      @end
      
      @implementation AppDelegate
      
      - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
          // Insert code here to initialize your application
      
          [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"zh"] forKey:@"AppleLanguages"];
          [[NSUserDefaults standardUserDefaults] synchronize];
      
          [self joinMeeting];
      }
      
      - (void)applicationWillTerminate:(NSNotification *)aNotification {
          // Insert code here to tear down your application
      }
      
      - (void)joinMeeting {
      }
      1. 在joinMeeting中添加构建入会信息,添加各项入会参数。
            NSString *meetingToken = @"";
            NSString *meetingDomain = @"";;
            NSString *meetingUUID = @"";
            NSString *memberUUID = @"";
            NSString *clientAppId = @"";
            NSString *slsInfo = @"";
            NSString *userId = @"";
            //构建入会信息,添加各项入会参数,详细信息请参考头文件AMUISDKMeetingConfig.h
            NSDictionary *meetingConfig = @{
                AMUISDKMeetingConfigClientAppId:clientAppId,
                AMUISDKMeetingConfigSlsInfo:slsInfo,
                AMUISDKMeetingConfigMeetingUUID:meetingUUID,
                AMUISDKMeetingConfigMemberUUID:memberUUID,
                AMUISDKMeetingConfigMeetingToken:meetingToken,
                AMUISDKMeetingConfigMeetingDomain:meetingDomain,
                AMUISDKMeetingConfigUserId:userId
            };
        重要
        • 入会信息配置项中,参数clientAppId、meetingUUID、memberUUID、meetingToken、meetingDomain、userId不可以为空,否则将会入会失败。通过调用检查会议口令接口获取,更多信息,请参见检查会议口令
        • userId设为-1,并且传入user_name,可以使用匿名入会,但是如果会中没有成员,不能匿名入会。
        参数说明
        参数描述
        clientAppId企业接入阿里云获得的唯一标识。
        slsInfo上传日志的地址。可以为空。
        meetingUUID会议的唯一标识。
        memberUUID成员的唯一标识。
        meetingToken会议校验令牌。
        meetingDomain会议连接的域名。
        userId会议中成员的ID。
      2. 在joinMeeting中构建界面定制信息,添加各项界面参数。
         //传入企业定制信息,会议信息和会议口令,详细信息请参考头文件AMUISDKGUIConfig.h
            NSDictionary *uiConfig = @{
                AMUISDKGuiConfigLogoBanner:@"",
                AMUISDKGuiConfigMeetingTopic:@"",
                AMUISDKGuiConfigMeetingCode:@"",
                AMUISDKGuiConfigMeetingRateUrl:@""
            };
      3. 在joinMeeting中新建窗体并入会。
            //新建主窗体,传入各项参数和回调
            _win = [[AMUISDKMeetingMainWindow alloc] initWithUIConfig:uiConfig meetingConfig:meetingConfig delegate:self];
        
            //设置日志回调
            [AMSDKLogger setLoggerPrinter:[demoLogger class]];
        
            //加入会议
            [_win joinMeeting];
    4. 添加回调。
      //已成功进入会议回调
      - (void) onMeetingJoined{
          NSLog(@"onMeetingJoined");
      }
      
      // 会议正常结束回调
      - (void) onMeetingFinish:(AMUISDKMeetingFinishCode) code reason:(NSString*) reason{
          NSLog(@"onMeetingFinish");
          [NSApp terminate:self];
      }
      
      // 入会异常回调
      - (void) onError:(AMUISDKMeetingErrorCode) code reason:(NSString*) reason{
          NSLog(@"onError");
      }
  5. 单击build and run开始编译运行。
    编译

枚举回调定义

会议配置枚举
//! 会议初始化配置项类型
typedef NSString *AMUISDKMeetingConfigKey;
//! 【Required】产品ID,类型NSString
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigClientAppId;
//! 【Required】SLS信息,类型NSString
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigSlsInfo;
//! 【Required】设置会议UUID,类型NSString
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigMeetingUUID;
//! 【Required】设置会议 Publisher UUID,类型NSString
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigMemberUUID;
//! 【Required】设置会议Token,类型NSString
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigMeetingToken;
//! 【Required】设置会议域名,类型NSString
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigMeetingDomain;
//! 【Required】设置人员UserId,类型NSString
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigUserId;
//! 【Optional】入会时是否静音,类型BOOL,默认NO
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigMuteAudio;
//! 【Optional】入会时是否开启扬声器,类型BOOL,默认YES
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigSpeakerEnabled;
//! 【Optional】入会时是否默认关闭本地摄像头,类型BOOL,默认NO
extern AMUISDKMeetingConfigKey const AMUISDKMeetingConfigMuteVideo;
//! 【Optional】入会是不开视频,只需要音频,不需要视频
AMUISDKMeetingConfigKey const AMUISDKMeetingConfigAudioOnly = @"audioOnly";
//! 【Optional】入会时没有检测到麦克风是否允许入会,类型BOOL,默认 YES
AMUISDKMeetingConfigKey const AMUISDKMeetingConfigAllowNoMic = @"allowNoMic";
UI配置枚举
//! UI初始化配置项类型
typedef NSString *AMUISDKGuiConfigKey;
//! 【Optional】会议产品Logo文件地址,类型NSString
extern AMUISDKGuiConfigKey const AMUISDKGuiConfigAppLogo;
//! 【Optional】企业Logo文件地址,类型NSString
extern AMUISDKGuiConfigKey const AMUISDKGuiConfigLogoBanner;
//! 【Optional】本场会议名称,类型NSString
extern AMUISDKGuiConfigKey const AMUISDKGuiConfigMeetingTopic;
//! 【Optional】本场会议时间区间,类型NSString
extern AMUISDKGuiConfigKey const AMUISDKGuiConfigMeetingTime;
//! 【Optional】本场会议口令信息,类型NSString
extern AMUISDKGuiConfigKey const AMUISDKGuiConfigMeetingCode;
//! 【Optional】本场会议分享URL,类型NSString
extern AMUISDKGuiConfigKey const AMUISDKGuiConfigMeetingUrl;
//! 【Optional】 会议结束后的评价页开放URL,需要传入一个评价页的h5
extern AMUISDKGuiConfigKey const AMUISDKGuiConfigMeetingRateUrl;
//! 【Optional】入会时是否开启会议成员邀请回调,类型BOOL,默认NO
extern AMUISDKGuiConfigKey const AMUISDKGuiConfigInviteMember;
回调状态码枚举
typedef NS_ENUM(NSInteger, AMUISDKMeetingErrorCode)
{
    //! 非法参数,接口调用参数不正确
    AMUISDKMeetingErrorCodeIllegalParameters = 0,
    //! 会议初始化失败,如无法获取会议信息,拉去配置
    AMUISDKMeetingErrorCodeInitializedFailed = 1,
    //! 设备无权限
    AMUISDKMeetingErrorCodeDevicePermissionNotGranted = 2,
    //! 无麦克风设备
    AMUISDKMeetingErrorCodeNoDevice = 3,
    //! 无法连接媒体服务
    AMUISDKMeetingErrorCodeMediaServerConnectFailed = 4,
    //! 会议并发满了
    AMUISDKMeetingErrorCodeRoomFull = 5,
    //! 入会超时
    AMUISDKMeetingErrorCodeJoinMeetingTimeout = 6,
    //!网络不可用
    AMUISDKMeetingErrorCodeNetworkUnAvailable = 7,
    //!媒体协商失败
    AMUISDKMeetingErrorCodeMediaNegotiationFailed = 8
};
typedef NS_ENUM(NSInteger, AMUISDKMeetingFinishCode)
{
    //!主动退出会议
    AMUISDKMeetingFinishCodeLeaveBySelf = 0,
    //!被动退出会议
    AMUISDKMeetingFinishCodeLeaveByKick = 1,
    //!挂断所有人
    AMUISDKMeetingFinishCodeLeaveByHangupAll = 2,
    //!同一个UserID的用户进入了会议
    AMUISDKMeetingFinishCodeOtherClientJoined = 3,
    //!会议评价完成
    AMUISDKMeetingFinishCodeMeetingRateComplete = 4,
    //!系统挂起
    AMUISDKMeetingFinishCodeSystemWillSleep = 5
};
typedef NS_ENUM(NSInteger, AMSDKUserStatusEvent) {
    //! 成员上线
    AMSDKUserStatusEventOnline                 =   0,
    //! 成员离线
    AMSDKUserStatusEventOffline                =   1,
    //!静音
    AMSDKUserStatusEventAudioMute              =   2,
    //!取消静音
    AMSDKUserStatusEventAudioUnMute            =   3,
    //!禁视频
    AMSDKUserStatusEventVideoMute              =   4,
    //!打开视频
    AMSDKUserStatusEventVideoUnMute            =   5,
    //!说话中
    AMSDKUserStatusEventStartTalking           =   6,
    //!结束说话
    AMSDKUserStatusEventStopTalking            =   7,
    //!主讲人切换
    AMSDKUserStatusEventMainSpeaker            =   8,
};