|
|
[TOC]
|
|
|
|
|
|
# 云直播观看端SDK开发指南
|
|
|
|
|
|
# 1.概述
|
... | ... | @@ -205,17 +207,14 @@ PS:其中3.8.0与3.11.2为SDK版本号可自行更改。 |
|
|
|
|
|
### 2.2.2 手动集成
|
|
|
|
|
|
1.将SDK文件夹内的HDBaseUtils文件夹下的HDBaseUtils.framework拖入项目中
|
|
|
|
|
|
2.根据自己项目是否需要连麦能力选择:将SDK文件夹内的Live_iOS_Play_SDK(带连麦能力)或Live_iOS_Play_SDK_NoMic(不带连麦能力)下的所有文件拖到项目中
|
|
|
|
|
|
3.General -> Framework,libraries,and Embedded Content中找到刚拖入项目的framework,并将对应的Embed项设置为Embed & Sign
|
|
|
1.将SDK文件夹内的所有文件拖到项目中
|
|
|
|
|
|
4.Targets -> Build Settings -> 搜索 "Enable Bitcode" 设置为 "NO"
|
|
|
|
|
|
5.Build Settings -> 搜索 "Validate Workspace" 设置为 “YES”
|
|
|
|
|
|
6.command + r 运行
|
|
|
```
|
|
|
command + b 编译,如果报错" file '...xxx/IJKMediaFramework.framework/IJKMediaFramework' for architecture arm64 "
|
|
|
解决方案:
|
|
|
Targets -> Build Settings -> 搜索 "Enable Bitcode" 设置为 "NO"
|
|
|
```
|
|
|
2.command + r 运行
|
|
|
|
|
|
```
|
|
|
如果报错" dyld: Library not loaded: @rpath/XXX.framework "
|
... | ... | @@ -252,7 +251,6 @@ Destination 选择 "Frameworks" -> |
|
|
```
|
|
|
|
|
|
## 2.4 错误码
|
|
|
|
|
|
服务错误类型
|
|
|
|
|
|
```
|
... | ... | @@ -262,7 +260,6 @@ Destination 选择 "Frameworks" -> |
|
|
ERROR_USELESS_INFO = 1002 没有获取到有用的视频信息
|
|
|
ERROR_PASSWORD = 1003 密码错误
|
|
|
```
|
|
|
|
|
|
系统错误类型
|
|
|
|
|
|
```
|
... | ... | @@ -368,25 +365,8 @@ done |
|
|
*/
|
|
|
- (id)initLoginWithParameter:(PlayParameter *)parameter;
|
|
|
|
|
|
/// 初始化SDK 3.18.0 new
|
|
|
/// 初始化SDK
|
|
|
/// @param parameter 参数
|
|
|
/// 必填参数 userId; //用户ID
|
|
|
/// 必填参数 roomId; //房间ID
|
|
|
/// 必填参数 viewerName; //用户名称
|
|
|
/// 必填参数 token; //房间密码
|
|
|
/// 必填参数 docParent; //文档父类窗口
|
|
|
/// 必填参数 docFrame; //文档区域
|
|
|
/// 必填参数 scalingMode; //屏幕适配方式
|
|
|
/// 必填参数 defaultColor; //ppt默认底色,不写默认为白色(16进制颜色字符串)
|
|
|
/// 必填参数 PPTScalingMode; //PPT适配方式
|
|
|
//PPT适配模式分为四种,
|
|
|
//1.拉伸填充,PPT内容全部展示在显示区域,会被拉伸或压缩,不会存在黑边
|
|
|
//2.等比居中,PPT内容保持原始比例,适应窗口展示在显示区域,会存在黑边
|
|
|
//3.等比填充,PPT内容保持原始比例,以横向或纵向适应显示区域,另一方向将会超出显示区域,超出部分会被裁减,不会存在黑边
|
|
|
//4.根据直播间文档显示模式的返回值进行设置(推荐)
|
|
|
/// 必填参数 pauseInBackGround; //后台是否继续播放,
|
|
|
/// 注意:如果开启后台播放需要打开 xcode->Capabilities->Background Modes->on->Audio,AirPlay,and Picture in Picture
|
|
|
/// (选填参数)viewercustomua; //用户自定义参数,需和后台协商,没有定制传@""
|
|
|
/// @param succed 初始化成功回调
|
|
|
/// @param player 播放视图回调 (流视图异步回调,存在回调多次;无延迟直播无需关注。)
|
|
|
/// @param failed 初始化失败回调
|
... | ... | @@ -396,6 +376,52 @@ done |
|
|
failed:(initFailedClosure)failed;
|
|
|
```
|
|
|
|
|
|
始化SDK(新)
|
|
|
|
|
|
| 方法 | 注释 |
|
|
|
| ------------------------------------------------- | --------- |
|
|
|
| (id)initSDKWithParameter: succed: player: failed: | 初始化SDK |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objc
|
|
|
/// 初始化SDK
|
|
|
/// @param parameter 参数
|
|
|
/// @param succed 初始化成功回调
|
|
|
/// @param player 播放视图回调 (流视图异步回调,存在回调多次;无延迟直播无需关注。)
|
|
|
/// @param failed 初始化失败回调
|
|
|
- (id)initSDKWithParameter:(PlayParameter *)parameter
|
|
|
succed:(initSuccedClosure)succed
|
|
|
player:(HDSPlayerViewClosure)player
|
|
|
failed:(initFailedClosure)failed;
|
|
|
```
|
|
|
|
|
|
| 参数 | 注释 |
|
|
|
| --------- | ------------------------------------------------------------ |
|
|
|
| parameter | 初始化SDK参数,其中 "playerParent","playerFrame" 已废弃删除,新的流视图由 HDSPlayerViewClosure 异步回调,自行处理 |
|
|
|
| succed | 初始化SDK成功回调 |
|
|
|
| player | 流视图异步回调,存在回调多次;“无延迟直播” 无需关注。 |
|
|
|
| failed | 初始化SDK失败回调 |
|
|
|
|
|
|
流视图(callback回调)
|
|
|
|
|
|
| 注意 |
|
|
|
| ------------------------------------------------------------ |
|
|
|
| **“新的流视图”** 通过 初始化SDK(initSDKWithParameter:)方法中的 **player:**,通过 **callback 返回 “流视图”** |
|
|
|
| **“流视图”** (属于UIView 类型),所在 **视图区域**,**视图大小** 可根据业务自行调整设置示例代码 |
|
|
|
|
|
|
```objc
|
|
|
_requestData = [[RequestData alloc] initSDKWithParameter:parameter succed:^(BOOL succed) {
|
|
|
|
|
|
} player:^(UIView * _Nonnull playerView) {
|
|
|
--> ** playerView ** 即为视频流视图
|
|
|
} failed:^(NSError *error, NSString *reason) {
|
|
|
|
|
|
}];
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
代理方法
|
|
|
|
|
|
```objc
|
... | ... | @@ -457,10 +483,6 @@ done |
|
|
* @brief 房间密码
|
|
|
*/
|
|
|
@property(nonatomic, copy)NSString *token;//房间密码
|
|
|
/**
|
|
|
* @brief 直播ID,回放时才用到(已废弃)
|
|
|
*/
|
|
|
@property(nonatomic, copy)NSString *liveId;//直播ID,回放时才用到(已废弃)
|
|
|
/**
|
|
|
* @brief 回放ID
|
|
|
*/
|
... | ... | @@ -468,9 +490,9 @@ done |
|
|
/**
|
|
|
* @brief 用户自定义参数,需和后台协商,没有定制传@""
|
|
|
*/
|
|
|
@property(nonatomic, copy)NSString *viewerCustomua;//用户自定义参数,需和后台协商,没有定制传@""
|
|
|
@property(nonatomic, copy)NSString *viewerCustomua;//用户自定义参数,需和后台协商,没有定制传@"" 长度不能超过40个字符
|
|
|
/**
|
|
|
* json格式字符串,可选,自定义用户信息,该信息会记录在用户访问记录中,用于统计分析使用(长度不能超过1000个字符,若直播间启用接口验证则该参数无效)如果不需要的话就不要传值
|
|
|
* json格式字符串,可选,自定义用户信息,该信息会记录在用户访问记录中,用于统计分析使用(长度不能超过200个字符,若直播间启用接口验证则该参数无效)如果不需要的话就不要传值
|
|
|
* 格式如下:
|
|
|
* viewercustominfo: '{"exportInfos": [ {"key": "城市", "value": "北京"}, {"key": "姓名", "value": "哈哈"}]}'
|
|
|
*/
|
... | ... | @@ -489,10 +511,10 @@ done |
|
|
@property(nonatomic,assign)CGRect docFrame;//文档区域
|
|
|
/**
|
|
|
* @brief 屏幕适配方式
|
|
|
* 0:IJKMPMovieScalingModeNone
|
|
|
* 1:IJKMPMovieScalingModeAspectFit
|
|
|
* 2:IJKMPMovieScalingModeAspectFill
|
|
|
* 3:IJKMPMovieScalingModeFill
|
|
|
* 0:HDSMediaScalingModeNone
|
|
|
* 1:HDSMediaScalingModeAspectFit
|
|
|
* 2:HDSMediaScalingModeAspectFill
|
|
|
* 3:HDSMediaScalingModeFill
|
|
|
*/
|
|
|
@property(assign, nonatomic)NSInteger scalingMode;//屏幕适配方式,含义见上面
|
|
|
/**
|
... | ... | @@ -544,46 +566,46 @@ done |
|
|
|
|
|
/**
|
|
|
* 视频播放状态
|
|
|
* HDMoviePlaybackStateStopped 播放停止
|
|
|
* HDMoviePlaybackStatePlaying 开始播放
|
|
|
* HDMoviePlaybackStatePaused 暂停播放
|
|
|
* HDMoviePlaybackStateInterrupted 播放间断
|
|
|
* HDMoviePlaybackStateSeekingForward 播放快进
|
|
|
* HDMoviePlaybackStateSeekingBackward 播放后退
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDMoviePlaybackState) {
|
|
|
HDMoviePlaybackStateStopped,
|
|
|
HDMoviePlaybackStatePlaying,
|
|
|
HDMoviePlaybackStatePaused,
|
|
|
HDMoviePlaybackStateInterrupted,
|
|
|
HDMoviePlaybackStateSeekingForward,
|
|
|
HDMoviePlaybackStateSeekingBackward,
|
|
|
* HDSMediaPlaybackStateStopped 播放停止
|
|
|
* HDSMediaPlaybackStatePlaying 开始播放
|
|
|
* HDSMediaPlaybackStatePaused 暂停播放
|
|
|
* HDSMediaPlaybackStateInterrupted 播放间断
|
|
|
* HDSMediaPlaybackStateSeekingForward 播放快进
|
|
|
* HDSMediaPlaybackStateSeekingBackward 播放后退
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDSMediaPlaybackState) {
|
|
|
HDSMediaPlaybackStateStopped,
|
|
|
HDSMediaPlaybackStatePlaying,
|
|
|
HDSMediaPlaybackStatePaused,
|
|
|
HDSMediaPlaybackStateInterrupted,
|
|
|
HDSMediaPlaybackStateSeekingForward,
|
|
|
HDSMediaPlaybackStateSeekingBackward,
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 视频加载状态
|
|
|
* HDMovieLoadStateUnknown 未知状态
|
|
|
* HDMovieLoadStatePlayable 视频未完成全部缓存,但已缓存的数据可以进行播放
|
|
|
* HDMovieLoadStatePlaythroughOK 完成缓存
|
|
|
* HDMovieLoadStateStalled 数据缓存已经停止,播放将暂停
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDMovieLoadState) {
|
|
|
HDMovieLoadStateUnknown,
|
|
|
HDMovieLoadStatePlayable,
|
|
|
HDMovieLoadStatePlaythroughOK,
|
|
|
HDMovieLoadStateStalled,
|
|
|
* HDSMediaLoadStateUnknown 未知状态
|
|
|
* HDSMediaLoadStatePlayable 视频未完成全部缓存,但已缓存的数据可以进行播放
|
|
|
* HDSMediaLoadStatePlaythroughOK 缓冲已经完成
|
|
|
* HDSMediaLoadStateStalled 缓冲已经开始
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDSMediaLoadState) {
|
|
|
HDSMediaLoadStateUnknown,
|
|
|
HDSMediaLoadStatePlayable,
|
|
|
HDSMediaLoadStatePlaythroughOK,
|
|
|
HDSMediaLoadStateStalled,
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 视频播放完成原因
|
|
|
* HDMovieFinishReasonPlaybackEnded 自然播放结束
|
|
|
* HDMovieFinishReasonUserExited 用户人为结束
|
|
|
* HDMovieFinishReasonPlaybackError 发生错误崩溃结束
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDMovieFinishReason) {
|
|
|
HDMovieFinishReasonPlaybackEnded,
|
|
|
HDMovieFinishReasonUserExited,
|
|
|
HDMovieFinishReasonPlaybackError,
|
|
|
* HDSMediaFinishReasonPlaybackEnded 自然播放结束
|
|
|
* HDSMediaFinishReasonUserExited 用户人为结束
|
|
|
* HDSMediaFinishReasonPlaybackError 发生错误崩溃结束
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDSMediaFinishReason) {
|
|
|
HDSMediaFinishReasonPlaybackEnded,
|
|
|
HDSMediaFinishReasonUserExited,
|
|
|
HDSMediaFinishReasonPlaybackError,
|
|
|
};
|
|
|
```
|
|
|
|
... | ... | @@ -619,7 +641,6 @@ typedef NS_ENUM(NSUInteger, HDUSER_REMIND) { |
|
|
/** 发送内容后缀 */
|
|
|
@property (nonatomic, copy) NSString *suffixContent;
|
|
|
```
|
|
|
|
|
|
新增 BanChatModel 类(用户禁言群发消息通知模型类)
|
|
|
|
|
|
```objc
|
... | ... | @@ -672,17 +693,6 @@ typedef NS_ENUM(NSUInteger, NEW_LOTTERY) { |
|
|
@property (nonnull, strong) NSDictionary *infos;
|
|
|
```
|
|
|
|
|
|
新增 LineModel 类 (切换线路清晰度类)(已废弃)
|
|
|
|
|
|
```objc
|
|
|
/** 清晰度 0-原画;200-流畅;300-标清; */
|
|
|
@property (nonatomic, copy) NSArray * _Nonnull quality;
|
|
|
/** 视频线路数 */
|
|
|
@property (nonatomic, assign) NSInteger videoLine;
|
|
|
/** 音频线路数 */
|
|
|
@property (nonatomic, assign) NSInteger audioLine;
|
|
|
```
|
|
|
|
|
|
新增 **HDQualityModel** 类 (切换线路清晰度)
|
|
|
|
|
|
```objc
|
... | ... | @@ -1835,16 +1845,6 @@ typedef NS_ENUM(NSInteger, HDSRoomCallType) { |
|
|
代理方法(可选)
|
|
|
|
|
|
```objc
|
|
|
/**
|
|
|
* @brief 房间的音视频线路 (已废弃)
|
|
|
* @param model LineModel 详情
|
|
|
*
|
|
|
* 废弃版本 3.14.0
|
|
|
* 兼容版本 2021年11月08日之后将不再维护
|
|
|
* 新方法 清晰度回调 - (void)HDReceivedVideoQuality:(NSDictionary *)dict;
|
|
|
* 线路回调 - (void)HDReceivedVideoAudioLines:(NSDictionary *)dict;
|
|
|
*/
|
|
|
- (void)HDReceivedVideoAudioLinesWithModel:(LineModel *)model;
|
|
|
/**
|
|
|
* The New Method (3.14.0)
|
|
|
* @brief 是否开启音频模式
|
... | ... | @@ -2394,34 +2394,34 @@ typedef NS_ENUM(NSInteger, HDSRoomCallType) { |
|
|
```objc
|
|
|
/**
|
|
|
* 视频播放状态
|
|
|
* HDMoviePlaybackStateStopped 播放停止
|
|
|
* HDMoviePlaybackStatePlaying 开始播放
|
|
|
* HDMoviePlaybackStatePaused 暂停播放
|
|
|
* HDMoviePlaybackStateInterrupted 播放间断
|
|
|
* HDMoviePlaybackStateSeekingForward 播放快进
|
|
|
* HDMoviePlaybackStateSeekingBackward 播放后退
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDMoviePlaybackState) {
|
|
|
HDMoviePlaybackStateStopped,
|
|
|
HDMoviePlaybackStatePlaying,
|
|
|
HDMoviePlaybackStatePaused,
|
|
|
HDMoviePlaybackStateInterrupted,
|
|
|
HDMoviePlaybackStateSeekingForward,
|
|
|
HDMoviePlaybackStateSeekingBackward,
|
|
|
* HDSMediaPlaybackStateStopped 播放停止
|
|
|
* HDSMediaPlaybackStatePlaying 开始播放
|
|
|
* HDSMediaPlaybackStatePaused 暂停播放
|
|
|
* HDSMediaPlaybackStateInterrupted 播放间断
|
|
|
* HDSMediaPlaybackStateSeekingForward 播放快进
|
|
|
* HDSMediaPlaybackStateSeekingBackward 播放后退
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDSMediaPlaybackState) {
|
|
|
HDSMediaPlaybackStateStopped,
|
|
|
HDSMediaPlaybackStatePlaying,
|
|
|
HDSMediaPlaybackStatePaused,
|
|
|
HDSMediaPlaybackStateInterrupted,
|
|
|
HDSMediaPlaybackStateSeekingForward,
|
|
|
HDSMediaPlaybackStateSeekingBackward,
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 视频加载状态
|
|
|
* HDMovieLoadStateUnknown 未知状态
|
|
|
* HDMovieLoadStatePlayable 视频未完成全部缓冲,但已缓冲的数据可以进行播放
|
|
|
* HDMovieLoadStatePlaythroughOK 缓冲已经完成
|
|
|
* HDMovieLoadStateStalled 缓冲已经开始
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDMovieLoadState) {
|
|
|
HDMovieLoadStateUnknown,
|
|
|
HDMovieLoadStatePlayable,
|
|
|
HDMovieLoadStatePlaythroughOK,
|
|
|
HDMovieLoadStateStalled,
|
|
|
* HDSMediaLoadStateUnknown 未知状态
|
|
|
* HDSMediaLoadStatePlayable 视频未完成全部缓冲,但已缓冲的数据可以进行播放
|
|
|
* HDSMediaLoadStatePlaythroughOK 缓冲已经完成
|
|
|
* HDSMediaLoadStateStalled 缓冲已经开始
|
|
|
*/
|
|
|
typedef NS_ENUM(NSUInteger, HDSMediaLoadState) {
|
|
|
HDSMediaLoadStateUnknown,
|
|
|
HDSMediaLoadStatePlayable,
|
|
|
HDSMediaLoadStatePlaythroughOK,
|
|
|
HDSMediaLoadStateStalled,
|
|
|
};
|
|
|
```
|
|
|
|
... | ... | @@ -2431,27 +2431,27 @@ typedef NS_ENUM(NSUInteger, HDMovieLoadState) { |
|
|
/**
|
|
|
* @brief 视频状态改变
|
|
|
* @param state
|
|
|
* HDMoviePlaybackStateStopped 播放停止
|
|
|
* HDMoviePlaybackStatePlaying 开始播放
|
|
|
* HDMoviePlaybackStatePaused 暂停播放
|
|
|
* HDMoviePlaybackStateInterrupted 播放间断
|
|
|
* HDMoviePlaybackStateSeekingForward 播放快进
|
|
|
* HDMoviePlaybackStateSeekingBackward 播放后退
|
|
|
* HDSMediaPlaybackStateStopped 播放停止
|
|
|
* HDSMediaPlaybackStatePlaying 开始播放
|
|
|
* HDSMediaPlaybackStatePaused 暂停播放
|
|
|
* HDSMediaPlaybackStateInterrupted 播放间断
|
|
|
* HDSMediaPlaybackStateSeekingForward 播放快进
|
|
|
* HDSMediaPlaybackStateSeekingBackward 播放后退
|
|
|
*/
|
|
|
- (void)HDMoviePlayBackStateDidChange:(HDMoviePlaybackState)state;
|
|
|
- (void)HDSMediaPlayBackStateDidChange:(HDSMediaPlaybackState)state;
|
|
|
/**
|
|
|
* @brief 视频加载状态
|
|
|
* @param state 播放状态
|
|
|
* HDMovieLoadStateUnknown 未知状态
|
|
|
* HDMovieLoadStatePlayable 视频未完成全部缓存,但已缓存的数据可以进行播放
|
|
|
* HDMovieLoadStatePlaythroughOK 完成缓存
|
|
|
* HDMovieLoadStateStalled 数据缓存已经停止,播放将暂停
|
|
|
* HDSMediaLoadStateUnknown 未知状态
|
|
|
* HDSMediaLoadStatePlayable 视频未完成全部缓存,但已缓存的数据可以进行播放
|
|
|
* HDSMediaLoadStatePlaythroughOK 缓冲已经完成
|
|
|
* HDSMediaLoadStateStalled 缓冲已经开始
|
|
|
*/
|
|
|
- (void)HDMovieLoadStateDidChange:(HDMovieLoadState)state;
|
|
|
- (void)HDSMediaLoadStateDidChange:(HDSMediaLoadState)state;
|
|
|
/**
|
|
|
* @brief 播放器初始化完成 (会多次回调)
|
|
|
*/
|
|
|
- (void)HDMediaPlaybackIsPreparedToPlayDidChange:(NSDictionary *)dict;
|
|
|
- (void)HDMediaPlaybackIsPreparedToPlayDidChange;
|
|
|
```
|
|
|
|
|
|
## 3.20 视频缓存速度
|
... | ... | @@ -2655,3 +2655,4 @@ error: Bundle only contains bitcode-marker /var/folders/s5/lnk362pd4cs0lmtn_43pp |
|
|
```
|
|
|
|
|
|
PS:直播、在线回放只有上述api会在子线程回调,其余的api均在主线程进行回调。
|
|
|
|