|
|
## CCRoomUI 接入文档
|
|
|
|
|
|
\[TOC\]
|
|
|
|
|
|
### 接入方式
|
|
|
| 接入方式 |
|
|
|
|------|
|
|
|
| 本地Pod集成 |
|
|
|
|
|
|
### 使用步骤
|
|
|
|
|
|
#### 第一步:引入CCRoomUI
|
|
|
|
|
|
将 **CCRoomUI文件夹** 放到自己的 **工程项目中**,与 **xxx.xcodeproj** 文件同一层级。如图:
|
|
|
|
|
|
![414-1](image/001.jpg)
|
|
|
|
|
|
#### 第二步:安装 Cocoapods(已安装 Cocoapods 请跳过第二步)
|
|
|
|
|
|
如何安装 Cocoapods,请百度搜索自行安装,安装后执行第三步。
|
|
|
|
|
|
#### 第三步:安装 CCRoomUI
|
|
|
|
|
|
1. 在电脑上打开 **终端(Terminal)**
|
|
|
2. 进入到 **工程项目文件夹中**
|
|
|
|
|
|
```plaintext
|
|
|
$ cd <Target Path>
|
|
|
```
|
|
|
3. 创建 pod
|
|
|
|
|
|
```plaintext
|
|
|
$ pod init
|
|
|
```
|
|
|
4. 编辑 Podfile
|
|
|
|
|
|
```plaintext
|
|
|
$ vim Podfile
|
|
|
```
|
|
|
|
|
|
进入编辑模式
|
|
|
|
|
|
```plaintext
|
|
|
$ i
|
|
|
```
|
|
|
|
|
|
拷贝集成命令,如图:
|
|
|
|
|
|
```plaintext
|
|
|
$ pod 'CCRoomUI', :path => './CCRoomUI/'
|
|
|
```
|
|
|
|
|
|
![](image/002.jpg)
|
|
|
|
|
|
点击 **esc** 键退出编辑,输入 :wq 进行保存并退出
|
|
|
|
|
|
```plaintext
|
|
|
$ :wq
|
|
|
```
|
|
|
5. 安装 CCRoomUI
|
|
|
|
|
|
```plaintext
|
|
|
$ pod install
|
|
|
```
|
|
|
|
|
|
安装完成后目录结构如图:
|
|
|
|
|
|
![](image/003.jpg)
|
|
|
6. 打开项目 **xxx.xcworkspace**
|
|
|
|
|
|
#### 第四步:接入 CCRoomUI
|
|
|
|
|
|
1. 编辑 **appdelegate.h** 文件,拷贝下面代码
|
|
|
|
|
|
```objective_c
|
|
|
@property (strong, nonatomic) UIWindow *window;
|
|
|
@property (nonatomic, assign, getter=isLaunchScreen) BOOL launchScreen; /**< 是否是横屏 */
|
|
|
- (void)addFuncView:(UIView *)view;
|
|
|
- (void)removeViewFuncView;
|
|
|
```
|
|
|
|
|
|
如图:
|
|
|
|
|
|
![414-5](image/004.jpg)
|
|
|
2. 编辑 **appdelegate.m** 文件
|
|
|
|
|
|
```objective_c
|
|
|
@property (nonatomic, strong) UIView *funcView;
|
|
|
|
|
|
|
|
|
- (void)updateLaunchScreenStatus:(NSString *)lanuchScreenStatus {
|
|
|
[self setLaunchScreen:[lanuchScreenStatus isEqualToString:@"YES"] ? YES : NO];
|
|
|
}
|
|
|
|
|
|
- (void)setLaunchScreen:(BOOL)launchScreen {
|
|
|
_launchScreen = launchScreen;
|
|
|
[self application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:nil];
|
|
|
}
|
|
|
|
|
|
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
|
|
|
if (self.isLaunchScreen) {
|
|
|
return UIInterfaceOrientationMaskLandscapeRight;
|
|
|
}
|
|
|
return UIInterfaceOrientationMaskPortrait;
|
|
|
}
|
|
|
|
|
|
- (void)addFuncView:(UIView *)view {
|
|
|
if ([self checkVisiable]) {
|
|
|
self.funcView = view;
|
|
|
[self.window addSubview:view];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)removeViewFuncView {
|
|
|
[self.funcView removeFromSuperview];
|
|
|
}
|
|
|
|
|
|
- (BOOL)checkVisiable {
|
|
|
UIViewController *vc = self.window.rootViewController;
|
|
|
if ([vc isKindOfClass:[UINavigationController class]]) {
|
|
|
UIViewController *tmp = [((UINavigationController *)vc).viewControllers lastObject];
|
|
|
if ([tmp presentedViewController]) {
|
|
|
return YES;
|
|
|
}
|
|
|
}
|
|
|
return NO;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
如图:
|
|
|
|
|
|
![414-6](image/005.jpg)
|
|
|
3. 编辑 **info.plist** 文件,添加 **隐私权限**
|
|
|
| Key | Type | Value |
|
|
|
|-----|------|-------|
|
|
|
| Privacy - Camera Usage Description | String | 需要获取您的相机权限, 开启后才可以进行扫码和视频直播 |
|
|
|
| Privacy - Microphone Usage Description | String | 需要获取您的麦克风权限, 开启后连麦时才会有声音 |
|
|
|
| Privacy - Photo Library Additions Usage Description | String | 是否允许添加照片 |
|
|
|
| Privacy - Photo Library Usage Description | String | 需要获取您的相册权限, 开启后才能进行图片直播 |
|
|
|
|
|
|
PS: 隐私权限和对应提示语可根据具体的使用功能进行配置,上述为使用完整 CCRoomUI 默认配置。
|
|
|
|
|
|
如图:
|
|
|
|
|
|
![414-7](image/006.jpg)
|
|
|
|
|
|
#### 第五步:初始化房间
|
|
|
|
|
|
##### 初始化直播
|
|
|
| 方法 | 注释 |
|
|
|
|----|----|
|
|
|
| (instancetype)initWithRoomName: liveConfig: | 初始化横屏直播 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
/// 初始化横屏直播
|
|
|
/// @param roomName 房间名
|
|
|
/// @param liveConfig 直播配置
|
|
|
- (instancetype)initWithRoomName:(NSString *)roomName liveConfig:(HDSLoginConfig *)liveConfig;
|
|
|
```
|
|
|
|
|
|
代理方法
|
|
|
|
|
|
```objective_c
|
|
|
/// 代理方法
|
|
|
@property (nonatomic, weak) id<HDSLoginProtocol>delegate;
|
|
|
```
|
|
|
|
|
|
##### 初始化竖屏直播
|
|
|
| 方法 | 注释 |
|
|
|
|----|----|
|
|
|
| (instancetype)initWithRoomName: liveConfig: | 初始化竖屏直播 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
/// 初始化竖屏直播
|
|
|
/// - Parameters:
|
|
|
/// - roomName: 房间名称
|
|
|
/// - liveConfig: 直播配置
|
|
|
- (instancetype)initWithRoomName:(NSString *)roomName liveConfig:(HDSLoginConfig *)liveConfig;
|
|
|
```
|
|
|
|
|
|
代理方法
|
|
|
|
|
|
```objective_c
|
|
|
/// 代理方法
|
|
|
@property (nonatomic, weak) id<HDSLoginProtocol>delegate;
|
|
|
```
|
|
|
|
|
|
##### 初始化在线回放
|
|
|
| 方法 | 注释 |
|
|
|
|----|----|
|
|
|
| (instancetype)initWithPlayBackConfig: | 初始化观看回放 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
/// 初始化观看回放
|
|
|
/// - Parameters:
|
|
|
/// - playBackConfig: 回放配置
|
|
|
- (instancetype)initWithPlayBackConfig:(HDSLoginConfig *)playBackConfig;
|
|
|
```
|
|
|
|
|
|
代理方法
|
|
|
|
|
|
```objective_c
|
|
|
/// 代理方法
|
|
|
@property (nonatomic, weak) id<HDSLoginProtocol>delegate;
|
|
|
```
|
|
|
|
|
|
##### 初始化离线回放
|
|
|
| 方法 | 注释 |
|
|
|
|----|----|
|
|
|
| (instancetype)initWithfileName: offlineConfig: | 初始化离线回放 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
/// 初始化离线回放
|
|
|
/// - Parameters:
|
|
|
/// - fileName: 文件名
|
|
|
/// - offlineConfig: 离线配置
|
|
|
- (instancetype)initWithfileName:(NSString *)fileName offlineConfig:(HDSLoginConfig *)offlineConfig;
|
|
|
```
|
|
|
|
|
|
代理方法
|
|
|
|
|
|
```objective_c
|
|
|
/// 代理方法
|
|
|
@property (nonatomic, weak) id<HDSLoginProtocol>delegate;
|
|
|
```
|
|
|
|
|
|
##### HDSLoginConfig (登录配置项)
|
|
|
| 字段 | 类型 | 注释 | 是否必须 |
|
|
|
|----|----|----|------|
|
|
|
| joinType | HDSJoinType | 加入类型 | 是 |
|
|
|
| roomId | String | 房间ID | 是 |
|
|
|
| userId | String | 用户ID | 是 |
|
|
|
| viewerName | String | 用户名 | 否 |
|
|
|
| token | String | 密码 | 否 |
|
|
|
| viewerCustomua | String | 接口验证 | 否 |
|
|
|
| viewercustominfo | String | 接口验证 | 否 |
|
|
|
| isPauseInBackGround | Bool | 后台是否暂停播放 | 否 |
|
|
|
| screenCaptureSwitch | Bool | 放录屏开关 | 否 |
|
|
|
| recordId | String | 在线回放ID (仅在线回放使用) | 是 |
|
|
|
| ccrPath | String | 离线回放CCR路径 (仅离线回放使用) | 是 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
/// 加入类型
|
|
|
@property (nonatomic, assign) HDSJoinType joinType;
|
|
|
/// 房间ID
|
|
|
@property (nonatomic, copy) NSString * _Nonnull roomId;
|
|
|
/// 账户ID
|
|
|
@property (nonatomic, copy) NSString * _Nonnull userId;
|
|
|
/// 用户名
|
|
|
@property (nonatomic, copy) NSString * _Nullable viewerName;
|
|
|
/// 密码
|
|
|
@property (nonatomic, copy) NSString * _Nullable token;
|
|
|
|
|
|
/// 接口验证(可选,非必需)viewerCustomua
|
|
|
@property (nonatomic, copy) NSString * _Nullable viewerCustomua;
|
|
|
/// 接口验证(可选,非必需)viewercustominfo
|
|
|
@property (nonatomic, copy) NSString * _Nullable viewercustominfo;
|
|
|
|
|
|
/// 后台是否暂停播放 YES 暂停后台播放 NO 允许后台播放
|
|
|
@property (nonatomic, assign) BOOL isPauseInBackGround;
|
|
|
/// 屏幕开关 YES 开启防录屏 NO 关闭防录屏
|
|
|
@property (nonatomic, assign) BOOL screenCaptureSwitch;
|
|
|
|
|
|
// MARK: - 回放ID
|
|
|
/// 在线回放ID (仅在线回放使用)
|
|
|
@property (nonatomic, copy) NSString * _Nonnull recordId;
|
|
|
|
|
|
// MARK: - CCR Path
|
|
|
/// 离线回放CCR路径 (仅离线回放使用)
|
|
|
@property (nonatomic, copy) NSString * _Nonnull ccrPath;
|
|
|
```
|
|
|
|
|
|
##### HDSJoinType
|
|
|
| 字段 | 注释 |
|
|
|
|----|----|
|
|
|
| HDSJoinTypePush | Push 进入 |
|
|
|
| HDSJoinTypeModal | Modal 进入 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
typedef NS_ENUM(NSUInteger, HDSJoinType) {
|
|
|
HDSJoinTypePush,
|
|
|
HDSJoinTypeModal,
|
|
|
};
|
|
|
```
|
|
|
|
|
|
##### HDSLoginSource
|
|
|
| 字段 | 注释 |
|
|
|
|----|----|
|
|
|
| HDSLoginSourceLive | 直播 |
|
|
|
| HDSLoginSourcePortraitModeLive | 竖屏直播 |
|
|
|
| HDSLoginSourcePlayback | 在线回放 |
|
|
|
| HDSLoginSourceOffline | 离线回放 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
typedef NS_ENUM(NSUInteger, HDSLoginSource) {
|
|
|
HDSLoginSourceLive,
|
|
|
HDSLoginSourcePortraitModeLive,
|
|
|
HDSLoginSourcePlayback,
|
|
|
HDSLoginSourceOffline,
|
|
|
};
|
|
|
```
|
|
|
|
|
|
##### HDSLoginProtocol
|
|
|
|
|
|
登录成功代理(非必需)
|
|
|
| 方法 | 注释 |
|
|
|
|----|----|
|
|
|
| (void)initSucced: | 登录成功代理 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
- (void)initSucced:(HDSLoginSource)sourceType;
|
|
|
```
|
|
|
|
|
|
登录失败代理(非必需)
|
|
|
| 方法 | 注释 |
|
|
|
|----|----|
|
|
|
| (void)initFailed: sourceType: | 登录失败代理 |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objective_c
|
|
|
- (void)initFailed:(NSString *)message sourceType:(HDSLoginSource)sourceType;
|
|
|
``` |
|
|
\ No newline at end of file |