... | ... | @@ -1204,7 +1204,7 @@ DWUPnPSubscriptionDelegate是接收到回调事件,以下是它方法的具体 |
|
|
|
|
|
## 2.1 下载功能的快速集成,请详见2.集成指南
|
|
|
|
|
|
## 2.2 DWDownloadSessionManager的使用。
|
|
|
## 2.2 DWDownloadSessionManager的使用
|
|
|
DWDownloadSessionManager是下载管理类,所有有关下载的操作,都是通过此对象来进行的。可根据自己的业务逻辑,来自行修改下载相关的设置。
|
|
|
|
|
|
以下是具体的属性及方法:
|
... | ... | @@ -1335,12 +1335,13 @@ DWDownloadSessionManager是下载管理类,所有有关下载的操作,都 |
|
|
*/
|
|
|
-(void)reStartDownloadUrlWithNewUrlString:(NSString *)newUrlString AndDownloadModel:(DWDownloadModel *)downloadModel;
|
|
|
|
|
|
|
|
|
/**
|
|
|
获取appdelegate,handleEventsForBackgroundURLSession事件回调
|
|
|
|
|
|
@param identifier identifier
|
|
|
@param completionHandler completionHandler
|
|
|
*/
|
|
|
-(void)setBackgroundSessionCompletionHandler:(void (^)())completionHandler;
|
|
|
-(void)setBackgroundSession:(NSString *)identifier CompletionHandler:(void (^)())completionHandler;
|
|
|
|
|
|
//3.x.x升级4.x.x以上版本所使用的过渡方法
|
|
|
/**
|
... | ... | @@ -1506,75 +1507,61 @@ DWDownloadModel对象对应具体的下载任务。 |
|
|
```
|
|
|
|
|
|
# 3.上传功能
|
|
|
注意事项:通常情况下,不可对同一视频多次使用第一种初始化方式初始化上传,这样会造成大量重复视频,增加你后期管理视频的同事的工作量,且CC视频会根据你的付费套餐对每天的上传次数有不同的限制,超过最大上传次数,当天便无法上传视频。
|
|
|
|
|
|
## 3.1 上传功能的使用
|
|
|
## 3.1 上传功能的快速集成,请详见2.集成指南
|
|
|
初始化DWUploader对象,调用start方法,即可开始上传视频。
|
|
|
|
|
|
```
|
|
|
//videoTitle不得为空 videoPath音视频文件路径
|
|
|
DWUploader *uploader = [[DWUploader alloc] initWithuserId:@"账号ID"
|
|
|
andKey:@"APIKey"
|
|
|
uploadVideoTitle:@"视频标题"
|
|
|
videoDescription:@"视频描述"
|
|
|
videoTag:@"视频tag"
|
|
|
videoPath:@"视频本地路径"
|
|
|
notifyURL:@"回调地址"];
|
|
|
|
|
|
//开始上传
|
|
|
[uploader start];
|
|
|
```
|
|
|
## 3.2 DWUploadSessionManager的使用
|
|
|
DWUploadSessionManager是上传管理类,所有有关上传的操作,都是通过此对象来进行的。可根据自己的业务逻辑,来自行修改上传相关的设置。
|
|
|
|
|
|
## 3.2 上传功能的回调及方法
|
|
|
以下是具体的属性及方法:
|
|
|
|
|
|
如下:
|
|
|
```
|
|
|
typedef void (^DWUploaderFinishBlock)();
|
|
|
typedef void (^DWErrorBlock)(NSError *error);
|
|
|
typedef void (^DWUploaderVideoContextForRetryBlock)(NSDictionary *videoContext);
|
|
|
typedef void (^DWUploaderProgressBlock)(float progress, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite);
|
|
|
|
|
|
/**
|
|
|
* 在该block获取上传进度,可以在block内更新UI,如更新上传进度条。
|
|
|
上传数据列表
|
|
|
*/
|
|
|
@property (copy, nonatomic)DWUploaderProgressBlock progressBlock;
|
|
|
@property(nonatomic,strong,readonly)NSArray <DWUploadModel *> * uploadModelList;
|
|
|
|
|
|
/**
|
|
|
* 上传完成时回调该block,可以在block内更新UI,如将视频标记为上传完成。
|
|
|
代理
|
|
|
*/
|
|
|
@property (copy, nonatomic)DWUploaderFinishBlock finishBlock;
|
|
|
@property(nonatomic,weak) id <DWUploadSessionManagerDelegate> delegate;
|
|
|
|
|
|
/**
|
|
|
* 上传失败时回调该block,可以在该block内更新UI,如将视频标记为上传失败。
|
|
|
初始化DWUploadSessionManager
|
|
|
|
|
|
@return DWUploadSessionManager对象
|
|
|
*/
|
|
|
@property (copy, nonatomic)DWErrorBlock failBlock;
|
|
|
+(DWUploadSessionManager *)manager;
|
|
|
|
|
|
/**
|
|
|
* 在该block内获取上传上下文,并保存上传上下文,用来实现断线续传。
|
|
|
*/
|
|
|
@property (copy, nonatomic)DWUploaderVideoContextForRetryBlock videoContextForRetryBlock;
|
|
|
|
|
|
/**
|
|
|
* 当遇到网络问题或服务器原因时上传暂停,回调该block。
|
|
|
*/
|
|
|
@property (copy, nonatomic)DWErrorBlock pausedBlock;
|
|
|
|
|
|
/*
|
|
|
*第一次请求成功后保存信息 发生异常后如果能获取到此信息 则调用initWithVideoContext:方法做断点续传
|
|
|
*/
|
|
|
@protocol DWUploaderDelegate <NSObject>
|
|
|
@optional
|
|
|
//第一次请求成功的回调
|
|
|
- (void)checkUploadWithFilePath:(NSString *)filePath;
|
|
|
@end
|
|
|
初始化上传对象
|
|
|
|
|
|
/**
|
|
|
文件路径
|
|
|
@param userId 用户ID,不能为nil
|
|
|
@param apikey 用户秘钥,不能为nil
|
|
|
@param title 视频标题,不能为nil
|
|
|
@param description 视频描述
|
|
|
@param tag 视频标签
|
|
|
@param path 视频路径,不能为nil
|
|
|
@param notifyURL 通知URL
|
|
|
@return 上传对象model
|
|
|
*/
|
|
|
@property (nonatomic,copy,readonly)NSString *videoPath;
|
|
|
+(DWUploadModel *)createUploadModelWithUserId:(NSString *)userId
|
|
|
Apikey:(NSString *)apikey
|
|
|
VideoTitle:(NSString *)title
|
|
|
VideoDescription:(NSString *)description
|
|
|
VideoTag:(NSString *)tag
|
|
|
VideoPath:(NSString *)videoPath
|
|
|
CategoryId:(NSString *)categoryId
|
|
|
NotifyURL:(NSString *)notifyURL;
|
|
|
|
|
|
/**
|
|
|
添加视频水印,请在上传开始前调用此方法。
|
|
|
添加视频水印,请在调用startWithUploadModel:方法前设置,否则不生效。
|
|
|
|
|
|
@param uploadModel DWUploadModel对象
|
|
|
@param text 水印文字内容, 1-50个字符,数字、字母、汉字,不填写则文字水印不生效
|
|
|
@param corner 水印位置0,左上 1右上 2左下 3右下,默认3,非必填
|
|
|
@param offsetX X轴偏移像素值,要求大于0,默认值5,超出视频大小按默认值,非必填
|
... | ... | @@ -1585,41 +1572,170 @@ typedef void (^DWUploaderProgressBlock)(float progress, NSInteger totalBytesWrit |
|
|
@param fontAlpha 透明度,[0-100],默认100,100为不透明,非必填
|
|
|
@return 是否设置成功。YES 设置成功,NO 设置失败,参数不合法
|
|
|
*/
|
|
|
-(BOOL)insertWaterMarkWithUploadModel:(DWUploadModel *)uploadModel
|
|
|
Text:(NSString *)text
|
|
|
Corner:(NSNumber *)corner
|
|
|
OffsetX:(NSNumber *)offsetX
|
|
|
OffsetY:(NSNumber *)offsetY
|
|
|
FontFamily:(NSNumber *)fontFamily
|
|
|
FontSize:(NSNumber *)fontSize
|
|
|
FontColor:(NSString *)fontColor
|
|
|
FontAlpha:(NSNumber *)fontAlpha;
|
|
|
|
|
|
-(BOOL)insertWaterMarkWithText:(NSString *)text
|
|
|
Corner:(NSNumber *)corner
|
|
|
OffsetX:(NSNumber *)offsetX
|
|
|
OffsetY:(NSNumber *)offsetY
|
|
|
FontFamily:(NSNumber *)fontFamily
|
|
|
FontSize:(NSNumber *)fontSize
|
|
|
FontColor:(NSString *)fontColor
|
|
|
FontAlpha:(NSNumber *)fontAlpha;
|
|
|
/**
|
|
|
保存视频文件,以供上传使用
|
|
|
|
|
|
@param videoPath 视频文件路径
|
|
|
@return 本地文件路径
|
|
|
*/
|
|
|
-(NSString *)moveToLocalWithVideoPath:(NSString *)videoPath;
|
|
|
|
|
|
/**
|
|
|
开始上传
|
|
|
开始上传任务
|
|
|
|
|
|
@param uploadModel DWUploadModel对象
|
|
|
*/
|
|
|
- (void)start;
|
|
|
-(void)startWithUploadModel:(DWUploadModel *)uploadModel;
|
|
|
|
|
|
|
|
|
/**
|
|
|
暂停上传
|
|
|
暂停上传任务
|
|
|
|
|
|
@param uploadModel DWUploadModel对象
|
|
|
*/
|
|
|
- (void)pause;
|
|
|
-(void)suspendWithUploadModel:(DWUploadModel *)uploadModel;
|
|
|
|
|
|
|
|
|
/**
|
|
|
继续上传
|
|
|
继续上传任务
|
|
|
|
|
|
@param uploadModel DWUploadModel对象
|
|
|
*/
|
|
|
- (void)resume;
|
|
|
-(void)resumeWithUploadModel:(DWUploadModel *)uploadModel;
|
|
|
|
|
|
/**
|
|
|
删除上传任务
|
|
|
|
|
|
@param uploadModel DWUploadModel对象
|
|
|
*/
|
|
|
-(void)deleteWithUploadModel:(DWUploadModel *)uploadModel;
|
|
|
|
|
|
/**
|
|
|
分类上传
|
|
|
@param categoryId 分类
|
|
|
获取appdelegate,handleEventsForBackgroundURLSession事件回调
|
|
|
|
|
|
@param identifier identifier
|
|
|
@param completionHandler completionHandler
|
|
|
*/
|
|
|
- (void)category:(NSString *)categoryId;
|
|
|
-(void)setUploadSession:(NSString *)identifier CompletionHandler:(void (^)())completionHandler;
|
|
|
|
|
|
```
|
|
|
|
|
|
注意事项:通常情况下,不可对同一视频多次使用第一种初始化方式初始化上传,这样会造成大量重复视频,增加你后期管理视频的同事的工作量,且CC视频会根据你的付费套餐对每天的上传次数有不同的限制,超过最大上传次数,当天便无法上传视频。
|
|
|
## 3.3 上传功能的回调
|
|
|
DWUploadSessionManagerDelegate,方法说明如下:
|
|
|
|
|
|
```
|
|
|
//开始上传
|
|
|
-(void)uploadSessionManagerBeginWithUploadModel:(DWUploadModel *)uploadModel;
|
|
|
|
|
|
//更新上传状态
|
|
|
-(void)uploadSessionManagerUploadModel:(DWUploadModel *)uploadModel WithState:(DWUploadState)state;
|
|
|
|
|
|
//更新上传进度
|
|
|
-(void)uploadSessionManagerUploadModel:(DWUploadModel *)uploadModel totalBytesSent:(int64_t)totalBytesSent WithExpectedToSend:(int64_t)expectedToSend;
|
|
|
|
|
|
//上传失败回调
|
|
|
-(void)uploadSessionManagerUploadModel:(DWUploadModel *)uploadModel WithError:(NSError *)error;
|
|
|
|
|
|
//后台任务完成时回调
|
|
|
-(void)uploadBackgroundSessionCompletion;
|
|
|
|
|
|
```
|
|
|
|
|
|
## 3.4 DWUploadModel数据模型的使用
|
|
|
DWUploadModel对象对应具体的上传任务。
|
|
|
|
|
|
以下是具体DWUploadModel中,包含的字段及含义:
|
|
|
|
|
|
```
|
|
|
|
|
|
///上传状态
|
|
|
@property(nonatomic,assign,readonly)DWUploadState state;
|
|
|
|
|
|
///视频标题
|
|
|
@property(nonatomic,strong,readonly)NSString * title;
|
|
|
|
|
|
///视频tag
|
|
|
@property(nonatomic,strong,readonly)NSString * tag;
|
|
|
|
|
|
///视频描述信息
|
|
|
@property(nonatomic,strong,readonly)NSString * desc;
|
|
|
|
|
|
///视频分类
|
|
|
@property(nonatomic,strong,readonly)NSString * categoryId;
|
|
|
|
|
|
///上传进度
|
|
|
@property(nonatomic,assign,readonly)CGFloat progress;
|
|
|
|
|
|
///上传文件总字节数
|
|
|
@property(nonatomic,assign,readonly)int64_t fileSize;
|
|
|
|
|
|
///已上传字节数
|
|
|
@property(nonatomic,assign,readonly)int64_t totalSentBytes;
|
|
|
|
|
|
///本次发送字节数
|
|
|
@property(nonatomic,assign,readonly)int64_t sentBytes;
|
|
|
|
|
|
///自定义参数
|
|
|
@property(nonatomic,copy)NSDictionary * otherInfo;
|
|
|
|
|
|
///视频id
|
|
|
@property(nonatomic,strong,readonly)NSString * videoId;
|
|
|
|
|
|
///回调地址
|
|
|
@property(nonatomic,strong,readonly)NSString * notifyURL;
|
|
|
|
|
|
///是否裁剪 @"1"为裁剪 @“0”不裁剪 不设置默认为不裁剪
|
|
|
@property(nonatomic,copy)NSString * isCrop;
|
|
|
|
|
|
@property(nonatomic,copy)NSString * ew;
|
|
|
|
|
|
///账号id
|
|
|
@property(nonatomic,strong,readonly)NSString * userId;
|
|
|
|
|
|
///视频水印
|
|
|
@property(nonatomic,strong,readonly)DWUploadWaterMarkModel * waterMark;
|
|
|
|
|
|
```
|
|
|
|
|
|
以下是具体DWUploadWaterMarkModel中,包含的字段及含义:
|
|
|
|
|
|
```
|
|
|
|
|
|
///水印文字内容, 1-50个字符,数字、字母、汉字,不填写则文字水印不生效
|
|
|
@property(nonatomic,strong,readonly)NSString * text;
|
|
|
|
|
|
///水印位置0,左上 1右上 2左下 3右下,默认3,非必填
|
|
|
@property(nonatomic,strong,readonly)NSNumber * corner;
|
|
|
|
|
|
///X轴偏移像素值,要求大于0,默认值5,超出视频大小按默认值,非必填
|
|
|
@property(nonatomic,strong,readonly)NSNumber * offsetX;
|
|
|
|
|
|
///offsetY Y轴偏移像素值,要求大于0,默认值5,超出视频大小按默认值,非必填
|
|
|
@property(nonatomic,strong,readonly)NSNumber * offsetY;
|
|
|
|
|
|
//字体类型:0,微软雅黑 1宋体 2黑体,默认0,非必填
|
|
|
@property(nonatomic,strong,readonly)NSNumber * fontFamily;
|
|
|
|
|
|
///字体大小,[0-100],默认12
|
|
|
@property(nonatomic,strong,readonly)NSNumber * fontSize;
|
|
|
|
|
|
///16进制字体颜色,如#FFFFFF,不能写#号,默认灰色D3D3D3,非必填
|
|
|
@property(nonatomic,strong,readonly)NSString * fontColor;
|
|
|
|
|
|
///透明度,[0-100],默认100,100为不透明,非必填
|
|
|
@property(nonatomic,strong,readonly)NSNumber * fontAlpha;
|
|
|
|
|
|
```
|
|
|
|
|
|
## 4.Demo的注意事项
|
|
|
Demo是使用SDK对接CC视频云的示例源码,Demo的设计旨在展示SDK各项功能的使用方法,Demo中的逻辑仅供参考,如果希望应用获得更好的使用体验,请根据自己的需求更改。
|
... | ... | @@ -1759,7 +1875,8 @@ ERROR_UPLOAD_FREQUENTACCESS|4004|访问过于频繁 |
|
|
ERROR_UPLOAD_NOTPERMISSION|4005|用户服务无权限
|
|
|
ERROR_UPLOAD_FAIL|4100|上传失败
|
|
|
ERROR_UPLOAD_ANALYSIS|4150|上传数据解析失败
|
|
|
|
|
|
ERROR_UPLOAD_RECEIVE|4301|获取上传服务器失败
|
|
|
ERROR_UPLOAD_FILEDAMAGED|4302|上传文件已损坏
|
|
|
|
|
|
### 5.2 通信日志的使用
|
|
|
SDK提供了DWLog模块用来打印HTTP通信日志,可以在App的任意位置开启或关闭打印HTTP通信日志等功能。下面是DWLog的使用方法:
|
... | ... | |