-
Notifications
You must be signed in to change notification settings - Fork 3
Home
daliang0101 edited this page Dec 21, 2017
·
3 revisions
Welcome to the KSVSShortVideoKit_iOS wiki!
- SDK鉴权:KSVSAuthService
- 录制页:KSVSRecordViewController(编辑、合成、上传等功能,由录制页直接调用对应接口实现,省去您接入的成本)
- 视频广场页:KSVSSquareViewController
- 视频播放页:KSVSPlayerViewController
- 头像上传:KSVSKS3UploadService
- 获取/删除已发布视频:KSVSUserInfoRequestService
- KSVSAuthService
/**
* @abstract 鉴权接口
* @param bundleIdentifier App包名
* @param ksvsToken KSVSDk鉴权所需的token(由金山云颁发)
* @param accessToken App Server下发的token(登录App后,由App Server后返回的token,可参考KSVSDemo部分)
* @param success 请求鉴权信息成功后的回调
* @param failure 请求鉴权信息失败后的回调(KSVSError错误码参考KSVSErrorCodeDefines.h)
*/
+ (void)authWithBundleIdentifier:(NSString *)bundleIdentifier
ksvsToken:(NSString *)ksvsToken
accessToken:(NSString *)accessToken
success:(void(^)(void))success
failure:(void(^)(KSVSError *ksvsError))failure;
调用示例:
[KSVSAuthService authWithBundleIdentifier:bundleId ksvsToken:ksvsToken accessToken:kCurrUser.token success:^{
// 在这里执行鉴权成功后的操作
} failure:^(KSVSError *ksvsError) {
// 在这里查看鉴权出错的信息
}];
- KSVSRecordViewController(目前仅支持push到此控制器)
/**
* 最短录制时长, 视频集合的总时长必须大于该值,默认为5s
*/
@property (nonatomic, assign) NSTimeInterval minRecDuration;
/**
* 最长录制时长,视频集合的总时长必须小于该值,当录制时长超过该值后内部自动停止录制, 默认sdk本身不限制,但必须大于minRecDuration
* 默认60s
*/
@property (nonatomic, assign) NSTimeInterval maxRecDuration;
/**
* @abstract 初始化录制页视图控制器(目前仅支持用push到此控制器)
* @param userId 用户id (App Server返回的,可参考KSVSDemo部分)
*/
- (instancetype)initWithUserId:(NSString *)userId;
调用示例:
KSVSRecordViewController *recordVC = [[KSVSRecordViewController alloc] initWithUserId:@"uid"];
[self.navigationController pushViewController:recordVC animated:YES];
- KSVSSquareViewController
/**
* @abstract 初始化广场页视图控制器
* @param userId App用户id(由App Server返回)
*/
- (instancetype)initWithUserId:(NSString *)userId;
调用示例:
KSVSSquareViewController *asquareVC = [[KSVSSquareViewController alloc] initWithUserId:@"uid"];
- KSVSPlayerViewController
/**
* @abstract 出始化播放页视图控制器
* @param videoModel 视频对象模型
* @param playerFrom 是否是从个人中心push的
*/
- (instancetype)initWithVideoModel:(KSVSVideoModel *)videoModel
playerFrom:(KSVSPlayerFrom)playerFrom;
调用示例:
KSVSPlayerViewController *playerVC = [[KSVSPlayerViewController alloc] initWithVideoModel:model playerFrom:KSVSPlayerFromPersonalCenter];
- KSVSKS3UploadService
/**
* @abstract 初始化上传对象
* @param userId 当前用户的id
*/
- (instancetype)initWithUserId:(NSString *)userId;
/**
* @abstract 上传头像
* @param headImage 相册或拍照选取的图片
* @param success 上传成功的回调,headImageUrl为头像在ks3上的地址(例如,上传成功后修改headImageView.image为headImage)
* @param failure 上传失败的回调
*/
- (void)uploadHeadImage:(UIImage *)headImage
success:(void(^)(NSString *headImageUrl))success
failure:(void(^)(KSVSError *ksvsError))failure;
调用示例:
KSVSKS3UploadService *ks3Service = [[KSVSKS3UploadService alloc] initWithUserId:kCurrUser.uid];
[ks3Service uploadHeadImage:_selectedHeadImage success:^(NSString *headImageUrl) {
// 在这里执行上传头像成功的操作(如:更新userModel头像地址为headImageUrl,修改headImageView.image为新头像等)
} failure:^(KSVSError *ksvsError) {
// 在这里查看上传头像失败的原因
}];
- KSVSUserInfoRequestService
/**
* @abstract 获取已发布视频列表
* @param userId 用户id
* @param page 第几页的数据
* @param size 每页最多返回数据条数
* @param completion 请求完成回调
*/
+ (void)fetchReleasedVideoWithUserId:(NSString *)userId
page:(NSInteger)page
size:(NSInteger)size
completion:(void(^)(KSVSReleasedVideoResponse *response ,KSVSError *ksvsError))completion;
调用示例:
__weak typeof(self) weakSelf = self;
[KSVSUserInfoRequestService fetchReleasedVideoWithUserId:kCurrUser.uid page:1 size:50 completion:^(KSVSReleasedVideoResponse *response, KSVSError *ksvsError) {
typeof(weakSelf) strongSelf = weakSelf;
if (!ksvsError) {
// 更新已发布视频列表
[strongSelf.releasedVideos addObjectsFromArray:response.Data.Videos];
[strongSelf.releasedVideoTable reloadData];
} else {
// 提示错误码
}
}];
/**
* @abstract 删除用户已发布的视频
* @param userId App用户id
* @parma videoId 视频id
* @param completion 删除请求结束后的回调(请求失败错误码参考KSVSErrorCodeDefines.h)
*/
+ (void)deleteReleasedVideoWithUserId:(NSString *)userId
videoId:(NSString *)videoId
completion:(void(^)(KSVSDeleteReleasedVideoResponse *response ,KSVSError *ksvsError))completion;
调用示例:
[KSVSUserInfoRequestService deleteReleasedVideoWithUserId:kCurrUser.uid videoId:model.Id completion:^(KSVSDeleteReleasedVideoResponse *response, KSVSError *ksvsError) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
typeof(weakSelf) strongSelf = weakSelf;
if (!ksvsError) {
// 删除数据源,更新已发布视频列表
[strongSelf.releasedVideos removeObjectAtIndex:indexPath.row];
[tableView reloadData];
} else {
// 提示错误码
}
}];
- DemoNetworkService包含了获取手机验证码、验证码登录、退出登录、获取个人信息、更新个人信息几个API
- 获取手机验证码
/**
* @abstract 获取手机验证码
* @param mobile 手机号
* @param complete 请求结束的回调
*/
+ (void)fetchVerificationCodeWithMobile:(NSString *)mobile
complete:(void(^)(DemoVerificationCodeResponse *response, DemoError *demoError))complete;
调用示例:
[DemoNetworkService fetchVerificationCodeWithMobile:_mobileTextField.text complete:^(DemoVerificationCodeResponse *response, DemoError *demoError) {
if (!demoError) {
// 获取验证码成功
} else {
// 获取验证码失败
}
}];
- 验证码登录
/**
* @abstract 用手机号和验证码登录
* @param mobile 手机号
* @param verCode 验证码
* @param complete 登录请求结束的回调
*/
+ (void)loginWithMobile:(NSString *)mobile
verCode:(NSString *)verCode
complete:(void(^)(DemoVerificationCodeLoginResponse *response, DemoError *demoError))complete;
调用示例:
[DemoNetworkService loginWithMobile:_mobileTextField.text verCode:_verCodeTextField.text
complete:^(DemoVerificationCodeLoginResponse *response, DemoError *demoError) {
if (!demoError) {
// 登录成功
} else {
// 登录失败
}
}];
- 退出登录
/**
* @abstract 退出登录
* @param complete 退出登录请求结束的回调
*/
+ (void)loginOutComplete:(void(^)(DemoLoginOutResponse *response, DemoError *demoError))complete;
调用示例:
[DemoNetworkService loginOutComplete:^(DemoLoginOutResponse *response, DemoError *demoError) {
if (!demoError) {
// 退出登录成功
[[NSNotificationCenter defaultCenter] postNotificationName:kDemoLoginTokenExpiredNotification object:nil];
} else {
// 退出登录失败
}
}];
- 获取个人信息(登录状态调用)
/**
* @abstract 获取个人信息
*/
+ (void)fetchProfileWithComplete:(void(^)(DemoProfileResponse *response, DemoError *demoError))complete;
调用示例:
[DemoNetworkService fetchProfileWithComplete:^(DemoProfileResponse *response, DemoError *demoError) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
typeof(weakSelf) strongSelf = weakSelf;
if (!demoError) {
// 获取个人信息成功(可以在这里更新个人信息)
} else {
// 获取个人信息失败
}
}];
- 更新个人信息
/**
* @abstract 更新个人信息
* @param headUrlPath 用户头像地址
* @param nickname 用户昵称
* @param gender 用户性别(true:女,false:男)
* @param complete 更新请求结束后的回调
*/
+ (void)updateProfileWithHeadUrlPath:(NSString *)headUrlPath
nickname:(NSString *)nickname
gender:(BOOL)gender
complete:(void(^)(DemoUpdateProfileResponse *response, DemoError *demoError))complete;
调用示例:
[DemoNetworkService updateProfileWithHeadUrlPath:@"headUrlPath" nickname:@"nickName" gender:YES
complete:^(DemoUpdateProfileResponse *response, DemoError *demoError) {
if (!demoError) {
// 更新个人信息成功
} else {
// 更新个人信息失败
}
}];