|
|
|
|
|
## 1.播放功能
|
|
|
|
|
|
### 1.1 DWVodVideoModel数据模型的使用
|
... | ... | @@ -336,10 +335,6 @@ DWPlayerView包含的属性及方法如下: |
|
|
*/
|
|
|
- (BOOL)isAirplayEnabled;
|
|
|
|
|
|
/**
|
|
|
获取当前播放器截图
|
|
|
*/
|
|
|
- (UIImage *)screenShot;
|
|
|
|
|
|
/**
|
|
|
获取可播放的持续时间
|
... | ... | @@ -1307,6 +1302,159 @@ DWUPnPSubscriptionDelegate是接收到回调事件,以下是它方法的具体 |
|
|
-(void)upnpSubscriptionWithError:(NSError *)error;
|
|
|
```
|
|
|
|
|
|
## 1.14 视频弹幕
|
|
|
|
|
|
### 1.14.1 视频弹幕类的说明
|
|
|
DWBarrageManager是SDK中的弹幕管理类,负责弹幕的获取及发送。
|
|
|
```
|
|
|
///视频id
|
|
|
@property(nonatomic,copy)NSString * videoId;
|
|
|
|
|
|
///代理
|
|
|
@property(nonatomic,weak)id <DWBarrageManagerDelegate> delegate;
|
|
|
|
|
|
/// 设置当前播放时间
|
|
|
/// @param time 当前播放时间
|
|
|
-(void)associationWithTimeDidChange:(float)time;
|
|
|
|
|
|
/// 发送弹幕
|
|
|
/// @param barrageModel 弹幕模型
|
|
|
-(void)sendBarrageWithBarrageModel:(DWBarrageModel *)barrageModel;
|
|
|
|
|
|
/// 销毁进行中的请求,只对获取弹幕请求有效,发送弹幕的请求不会被销毁。
|
|
|
- (void)cancelRequest;
|
|
|
```
|
|
|
DWBarrageManagerDelegate方法如下:
|
|
|
```
|
|
|
//收到弹幕响应回调
|
|
|
-(void)getBarrageManager:(DWBarrageManager *)barrageManager BarrageList:(NSArray <DWBarrageModel *> *)barrageList WithError:(NSError *)error;
|
|
|
//发送弹幕回调
|
|
|
-(void)sendBarrageManager:(DWBarrageManager *)barrageManager BarrageModel:(DWBarrageModel *)sendBarrageModel WithError:(NSError *)error;
|
|
|
```
|
|
|
|
|
|
每一条弹幕对应一个DWBarrageModel对象,具体的含义如下:
|
|
|
```
|
|
|
/// 初始化方法
|
|
|
/// @param content 字幕内容
|
|
|
/// @param fc 字幕颜色,eg:0xffffff
|
|
|
/// @param pt 弹幕时间,单位毫秒
|
|
|
-(instancetype)initWithContent:(NSString *)content Fc:(NSString *)fc Pt:(NSInteger)pt;
|
|
|
|
|
|
///字幕内容
|
|
|
@property(nonatomic,strong,readonly)NSString * content;
|
|
|
|
|
|
///字幕颜色
|
|
|
@property(nonatomic,strong,readonly)NSString * fc;
|
|
|
|
|
|
///播放时间点,单位:毫秒
|
|
|
@property(nonatomic,assign,readonly)NSInteger pt;
|
|
|
```
|
|
|
|
|
|
### 1.14.2 视频弹幕的获取
|
|
|
1.初始化DWBarrageManager对象,并设置delegate。
|
|
|
```
|
|
|
-(DWBarrageManager *)barrageManager
|
|
|
{
|
|
|
if (!_barrageManager) {
|
|
|
_barrageManager = [[DWBarrageManager alloc]init];
|
|
|
_barrageManager.delegate = self;
|
|
|
}
|
|
|
return _barrageManager;;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
2.关联videoId
|
|
|
在设置DWVodVideoModel/DWDownloadModel对象时,关联videoId。
|
|
|
```
|
|
|
//关联在线视频videoId
|
|
|
-(void)setVodVideo:(DWVodVideoModel *)videoModel
|
|
|
{
|
|
|
......
|
|
|
|
|
|
//设置videoId,关联弹幕
|
|
|
self.barrageManager.videoId = self.videoModel.videoId;
|
|
|
|
|
|
......
|
|
|
}
|
|
|
//关联离线视频videoId
|
|
|
-(void)playLocalVideo:(DWDownloadModel *)downloadModel
|
|
|
{
|
|
|
......
|
|
|
|
|
|
//设置videoId,关联弹幕
|
|
|
self.barrageManager.videoId = self.downloadModel.videoId;
|
|
|
|
|
|
......
|
|
|
}
|
|
|
```
|
|
|
|
|
|
3.关联播放时间点
|
|
|
在DWPlayerView播放进度回调中,同步播放时间。
|
|
|
```
|
|
|
- (void)videoPlayer:(DWPlayerView *)playerView timeDidChange:(float)time
|
|
|
{
|
|
|
......
|
|
|
|
|
|
//SDK关联当前播放时间
|
|
|
[self.barrageManager associationWithTimeDidChange:time];
|
|
|
//弹幕加载
|
|
|
[self addNewBarrageWithTime:time];
|
|
|
|
|
|
......
|
|
|
}
|
|
|
```
|
|
|
|
|
|
4.收到DWBarrageManagerDelegate回调。
|
|
|
```
|
|
|
//收到弹幕响应回调
|
|
|
-(void)getBarrageManager:(DWBarrageManager *)barrageManager BarrageList:(NSArray <DWBarrageModel *> *)barrageList WithError:(NSError *)error
|
|
|
{
|
|
|
if (error) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
self.barragesArray = barrageList;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 1.14.3 视频弹幕的发送
|
|
|
初始化及关联videoId同1.14.2中的前两步。
|
|
|
1.点击弹幕发送按钮,通过内容,颜色,及发送时间初始化DWBarrageModel对象。
|
|
|
```
|
|
|
-(void)barrageBgViewSendWithContent:(NSString *)content Fc:(NSString *)fc
|
|
|
{
|
|
|
if (!self.readyToPlay) {
|
|
|
[@"正在加载视频,请稍后" showAlert];
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//发送弹幕
|
|
|
//初始化弹幕模型
|
|
|
DWBarrageModel * barrageModel = [[DWBarrageModel alloc]initWithContent:content Fc:fc Pt:(NSInteger)(self.currentPlayDuration * 1000)];
|
|
|
|
|
|
//调用方法,发送弹幕
|
|
|
[self.barrageManager sendBarrageWithBarrageModel:barrageModel];
|
|
|
}
|
|
|
```
|
|
|
|
|
|
2.收到DWBarrageManagerDelegate回调。
|
|
|
```
|
|
|
//发送弹幕回调
|
|
|
-(void)sendBarrageManager:(DWBarrageManager *)barrageManager BarrageModel:(DWBarrageModel *)sendBarrageModel WithError:(NSError *)error
|
|
|
{
|
|
|
if (error) {
|
|
|
//error存在,证明弹幕发送失败
|
|
|
[NSString stringWithFormat:@"发送失败 %@",error.localizedDescription];
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
[self.barrageBgView clearTextField];
|
|
|
|
|
|
//加载自己发送的弹幕
|
|
|
[self setBarrageWithModel:sendBarrageModel Send:YES];
|
|
|
}
|
|
|
```
|
|
|
|
|
|
# 2.下载功能
|
|
|
|
|
|
## 2.1 下载功能的快速集成,请详见2.集成指南
|
... | ... | @@ -1962,6 +2110,8 @@ ERROR_AFINFO_TYPENOTEXIST|1303|该用户无type对应类型的广告位 |
|
|
ERROR_AFINFO_NOTAD|1304|该用户type类型下无广告
|
|
|
ERROR_AFINFO_DATA|1305|数据查询异常
|
|
|
ERROR_AFINFO_ANALYSIS|1306|广告数据解析失败
|
|
|
ERROR_BARRAGE_PARAMS|1400|弹幕参数错误
|
|
|
ERROR_BARRAGE_ANALYSIS|1401|弹幕数据解析失败
|
|
|
ERROR_PLAYER_CREATE|2000|播放器创建失败
|
|
|
ERROR_VIDEO_PLAYERROR|2001|播放失败
|
|
|
ERROR_QUALITY_NOTEXIST|2002|未查找到清晰度
|
... | ... | |