|
|
[TOC]
|
|
|
|
|
|
# 云直播离线回放SDK开发指南
|
|
|
|
|
|
# 1.概述
|
|
|
|
|
|
## 1.1 阅读对象
|
... | ... | @@ -201,7 +205,6 @@ PS:其中3.8.0与3.11.2为SDK版本号可自行更改。 |
|
|
解决方案:
|
|
|
Targets -> Build Settings -> 搜索 "Enable Bitcode" 设置为 "NO"
|
|
|
```
|
|
|
|
|
|
2.command + r 运行
|
|
|
|
|
|
```
|
... | ... | @@ -248,7 +251,6 @@ Destination 选择 "Frameworks" -> |
|
|
ERROR_USELESS_INFO = 1002 没有获取到有用的视频信息
|
|
|
ERROR_PASSWORD = 1003 密码错误
|
|
|
```
|
|
|
|
|
|
系统错误类型
|
|
|
|
|
|
```
|
... | ... | @@ -300,23 +302,56 @@ Destination 选择 "Frameworks" -> |
|
|
|
|
|
3.1.1 调用方法
|
|
|
|
|
|
```objective-c
|
|
|
/**
|
|
|
* @brief 初始化
|
|
|
* @param parameter 配置参数信息
|
|
|
* 必填参数 docFrame; //文档区域
|
|
|
* 必填参数 docParent; //文档父类窗口
|
|
|
* 必填参数 playerParent; //视频父类窗口
|
|
|
* 必填参数 playerFrame; //视频区域
|
|
|
* 必填参数 scalingMode; //屏幕适配方式
|
|
|
* 必填参数 destination; //下载文件解压到的目录路径(离线下载相关)
|
|
|
* 必填参数 defaultColor; //ppt默认底色,不写默认为白色
|
|
|
* 必填参数 PPTScalingMode; //ppt展示模式,建议值为2
|
|
|
* 必填参数 pauseInBackGround; //后台是否继续播放,注意:如果开启后台播放需要打开 xcode->Capabilities->Background Modes->on->Audio,AirPlay,and Picture in Picture
|
|
|
*/
|
|
|
- (id)initWithParameter:(PlayParameter *)parameter;
|
|
|
| 方法 | 注释 |
|
|
|
| ------------------------------------------------- | --------- |
|
|
|
| (id)initSDKWithParameter: succed: player: failed: | 初始化SDK |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objc
|
|
|
/// 初始化
|
|
|
/// @param parameter 配置参数信息
|
|
|
/// 必填参数 docFrame;
|
|
|
/// 必填参数 docParent;
|
|
|
/// 必填参数 scalingMode;
|
|
|
/// 必填参数 destination;
|
|
|
/// 必填参数 defaultColor;
|
|
|
/// 必填参数 PPTScalingMode;
|
|
|
/// 必填参数 pauseInBackGround;
|
|
|
- (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
|
|
|
_offlinePlayBack = [[OfflinePlayBack alloc] initSDKWithParameter:parameter succed:^(BOOL succed) {
|
|
|
|
|
|
} player:^(UIView * _Nonnull playerView) {
|
|
|
--> ** playerView ** 即为视频流视图
|
|
|
} failed:^(NSError *error, NSString *reason) {
|
|
|
|
|
|
}];
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
代理方法
|
|
|
|
|
|
```objective-c
|
... | ... | @@ -345,6 +380,7 @@ Destination 选择 "Frameworks" -> |
|
|
配置参数:PlayParameter的属性如下
|
|
|
|
|
|
```objective-c
|
|
|
|
|
|
/**
|
|
|
* @brief 文档父类窗口
|
|
|
*/
|
... | ... | @@ -354,25 +390,17 @@ Destination 选择 "Frameworks" -> |
|
|
*/
|
|
|
@property(nonatomic,assign)CGRect docFrame;//文档区域
|
|
|
/**
|
|
|
* @brief 视频父类窗口
|
|
|
*/
|
|
|
@property(nonatomic,strong)UIView *playerParent;//视频父类窗口
|
|
|
/**
|
|
|
* @brief 视频区域
|
|
|
*/
|
|
|
@property(nonatomic,assign)CGRect playerFrame;//视频区域
|
|
|
/**
|
|
|
* @brief
|
|
|
* 0:IJKMPMovieScalingModeNone
|
|
|
* 1:IJKMPMovieScalingModeAspectFit
|
|
|
* 2:IJKMPMovieScalingModeAspectFill
|
|
|
* 3:IJKMPMovieScalingModeFill
|
|
|
* @brief 屏幕适配方式
|
|
|
* 0:HDSMediaScalingModeNone
|
|
|
* 1:HDSMediaScalingModeAspectFit
|
|
|
* 2:HDSMediaScalingModeAspectFill
|
|
|
* 3:HDSMediaScalingModeFill
|
|
|
*/
|
|
|
@property(assign, nonatomic)NSInteger scalingMode;//屏幕适配方式,含义见上面
|
|
|
/**
|
|
|
* @brief ppt默认底色,不写默认为白色
|
|
|
* @brief ppt默认底色,不写默认为白色(@"#FFFFFF")
|
|
|
*/
|
|
|
@property(nonatomic,strong)UIColor *defaultColor;//ppt默认底色,不写默认为白色
|
|
|
@property(nonatomic, copy) NSString *defaultColor;//ppt默认底色,不写默认为白色(@"#FFFFFF")
|
|
|
/**
|
|
|
* @brief /后台是否继续播放,注意:如果开启后台播放需要打开 xcode->Capabilities->Background Modes->on->Audio,AirPlay,and Picture in Picture
|
|
|
*/
|
... | ... | @@ -404,7 +432,13 @@ Destination 选择 "Frameworks" -> |
|
|
PlayParameter *parameter = [[PlayParameter alloc] init];
|
|
|
//配置PlayParameter里面的属性,如userId,roomId等!
|
|
|
第二步实例化RequestData类
|
|
|
_offlinePlayBack = [[OfflinePlayBack alloc] initWithParameter:parameter];
|
|
|
_offlinePlayBack = [[OfflinePlayBack alloc] initSDKWithParameter:parameter succed:^(BOOL succed) {
|
|
|
|
|
|
} player:^(UIView * _Nonnull playerView) {
|
|
|
--> ** playerView ** 即为视频流视图
|
|
|
} failed:^(NSError *error, NSString *reason) {
|
|
|
|
|
|
}];
|
|
|
_offlinePlayBack.delegate = self;
|
|
|
第三步添加代理
|
|
|
_offlinePlayBack.delegate = self;
|
... | ... | @@ -428,19 +462,6 @@ Destination 选择 "Frameworks" -> |
|
|
- (void)offline_loadVideoFail;
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
**至此您的项目已经可以运行了,并且已经集成好了视频基本功能;如果不需要文档功能则不配置文档相关属性即可,另外添加文档功能写一个定时器在视频开始播放时调用下面的方法即可**
|
|
|
|
|
|
```objective-c
|
|
|
/**
|
|
|
* (已废弃)
|
|
|
* @brief time:从直播开始到现在的秒数,SDK会在画板上绘画出来相应的图形
|
|
|
* 该方法已废弃:配置完SDK基本信息,开始播放会自行播放文档,不需求再次处理;!!!获取播放时间通过代理方法获取: - (void)HDPlayerCurrentTime:(NSTimeInterval)currentTime totalTime:(NSTimeInterval)totalTime;
|
|
|
*/
|
|
|
- (void)continueFromTheTime:(NSInteger)time;
|
|
|
```
|
|
|
|
|
|
代理方法 (可选)
|
|
|
|
|
|
```objective-c
|
... | ... | @@ -483,18 +504,6 @@ Destination 选择 "Frameworks" -> |
|
|
* @brief 销毁文档和视频,清除视频和文档的时候需要调用,推出播放页面的时候也需要调用
|
|
|
*/
|
|
|
- (void)requestCancel;
|
|
|
/**
|
|
|
* @brief time:从直播开始到现在的秒数,SDK会在画板上绘画出来相应的图形
|
|
|
*/
|
|
|
- (void)continueFromTheTime:(NSInteger)time;
|
|
|
/**
|
|
|
* @brief 改变播放器frame
|
|
|
*/
|
|
|
- (void)changePlayerFrame:(CGRect) playerFrame;
|
|
|
/**
|
|
|
* @brief 改变播放器父窗口
|
|
|
*/
|
|
|
- (void)changePlayerParent:(UIView *) playerParent;
|
|
|
/**
|
|
|
* @brief 播放器暂停
|
|
|
*/
|
... | ... | @@ -578,11 +587,6 @@ Destination 选择 "Frameworks" -> |
|
|
3.3.2 主动方法(可选)
|
|
|
|
|
|
```objective-c
|
|
|
/**
|
|
|
* @brief time:从直播开始到现在的秒数,SDK会在画板上绘画出来相应的图形
|
|
|
*/
|
|
|
- (void)continueFromTheTime:(NSInteger)time;
|
|
|
|
|
|
/**
|
|
|
* @brief 获取文档区域内白板或者文档本身的宽高比,返回值即为宽高比,做屏幕适配用
|
|
|
*/
|
... | ... | @@ -596,18 +600,6 @@ Destination 选择 "Frameworks" -> |
|
|
* @brief 改变文档父窗口
|
|
|
*/
|
|
|
- (void)changeDocParent:(UIView *) docParent;
|
|
|
/**
|
|
|
* @brief 主动调用方法 用于调整PPT缩放模式 (已废弃)
|
|
|
* @param docFrame 文档的frame
|
|
|
* @param PPTScalingMode PPT缩放模式
|
|
|
* 1 = 拉伸填充:PPT内容全部展示在显示区域,会被拉伸或压缩,不会存在黑边
|
|
|
* 2 = 等比居中:PPT内容保持原始比例,适应窗口展示在显示区域,会存在黑边
|
|
|
* 3 = 等比填充:PPT内容保持原始比例,以横向或纵向适应显示区域,另一方向将会超出显示区域,超出部分会被裁减,不会存在黑边
|
|
|
*
|
|
|
* 需要调整docFrame 请直接调用 - (void)changeDocFrame:(CGRect)docFrame;方法
|
|
|
*/
|
|
|
- (void)changeDocFrame:(CGRect)docFrame withPPTScalingMode:(NSInteger)PPTScalingMode;
|
|
|
|
|
|
/**
|
|
|
* @brief 主动调用方法 用于调整PPT缩放模式
|
|
|
* @param pptScalingMode PPT缩放模式
|
... | ... | @@ -710,46 +702,46 @@ Destination 选择 "Frameworks" -> |
|
|
```objective-c
|
|
|
/**
|
|
|
* 视频播放状态
|
|
|
* 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,
|
|
|
};
|
|
|
```
|
|
|
|
... | ... | @@ -759,34 +751,36 @@ typedef NS_ENUM(NSUInteger, HDMovieFinishReason) { |
|
|
/**
|
|
|
* @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 视频播放完成原因
|
|
|
* @param reason 原因
|
|
|
* HDMovieFinishReasonPlaybackEnded 自然播放结束
|
|
|
* HDMovieFinishReasonUserExited 用户人为结束
|
|
|
* HDMovieFinishReasonPlaybackError 发生错误崩溃结束
|
|
|
* HDSMediaFinishReasonPlaybackEnded 自然播放结束
|
|
|
* HDSMediaFinishReasonUserExited 用户人为结束
|
|
|
* HDSMediaFinishReasonPlaybackError 发生错误崩溃结束
|
|
|
*/
|
|
|
- (void)HDMoviePlayerPlaybackDidFinish:(HDMovieFinishReason)reason;
|
|
|
- (void)HDSMediaPlayerPlaybackDidFinish:(HDSMediaFinishReason)reason;
|
|
|
```
|
|
|
|
|
|
## 3.9 防录屏
|
|
|
|
|
|
PS:防录屏功能拆分到demo层处理,具体实现参考 4.0.0 demo
|
|
|
|
|
|
# 4.常见问题
|
|
|
|
... | ... | |