• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

swift 阿里云短视频上传 - VODUploadClient - Sinner_Yun

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

swift 阿里云短视频上传 - VODUploadClient

 1 //视频上传
 2     private func upLoadVideo(videoPath: String){
 3         
 4         let Auth = "eyJTZWN1cml0eVRva2VuIjoiQ0FJUzBBUjFxNkZ0NUIyeWZTaklyNG52TGU3MTJZcEZnN2VJV0g3RHFETm1PY3hxdWZETmlEejJJSDlJZEhWb0FPOGZ2dlUwbTJ0WTdQc1psclV4L1NmdTJrS3ZSaHBrUnZ2WkVwUHR3eklpai9nTFpaRWlhelJteWhlZm81WG1QWEZUUd5akt2aW9TIiwiRXhwaXJhdGlvbiI6IjM2MDAiLCJSZWdpb24iOiJjbi1zaGFuZ2hhaSJ9"
 5         let Address = "eyJFbmRwb2ludCI6Ih0dHBzOi8vb3NzLWNuLXNoYW5naGFpLmFsaXl1bmNzLmNvbSIsIkJ1Y2tldCI6Im91Jzdi8zMmIxYWFkNi0xNmQ0ZTMzZWU0Mi8zMmIxYWFkNi0xNmQ0ZTMzZWU0Mi5tcDQifQ=="
 6         
 7         self.uploader = VODUploadClient.init()
 8         weak var weakSelf = self
 9         let lister: VODUploadListener = VODUploadListener.init()
10         
11         //上传开始:(^OnUploadStartedListener) (UploadFileInfo* fileInfo),fileInfo中存放的是视频信息
12         lister.started = {(info) in
13             XLOG("开始上传")
14             XLOG(info?.filePath)
15             weakSelf?.uploader?.setUploadAuthAndAddress(info, uploadAuth: Auth, uploadAddress: Address)
16         }
17 
18         //上传进度:(UploadFileInfo* fileInfo, long uploadedSize, long totalSize), uploadedSize为上传数据量, totalSize为总文件大小
19         lister.progress = {(info, uploadeSize, totalSize) in
20             XLOG("\(uploadeSize)===== 上传中 =====\(totalSize)")
21         }
22 
23         //上传完成:(UploadFileInfo* fileInfo, VodUploadResult* result), result存放了视频id或者文件(图片)的文件名
24         lister.finish = {(info, result) in
25             XLOG("上完成")
26             XLOG(result)
27             XLOG(result?.videoId)
28         }
29         
30         //上传失败:(UploadFileInfo* fileInfo, NSString *code, NSString * message),code为错误码,messgae为错误信息
31         lister.failure = {(info, code, msg) in
32             XLOG("上传失败")
33             XLOG(msg)
34         }
35         
36         //上传凭证过期:(^OnUploadTokenExpiredListener) ()在这个回调中重新获取上传凭证
37         lister.expire = {() in
38             XLOG("凭证过期了")
39             weakSelf?.uploader?.resume(withAuth: Auth)
40         }
41         
42         //重新获取凭证:(^OnUploadRertyResumeListener) ()这个回调表示重新获取上传凭证成功
43         lister.retryResume = {() in
44             XLOG("要重新获取凭证")
45         }
46         
47         //重新上传:(^OnUploadRertyListener) ()这个回调表示重新开始上传
48         lister.retry = {() in
49             XLOG("要重新上传了")
50         }
51         
52         self.uploader?.setListener(lister)
53         
54         
55         let  vodInfo: VodInfo = VodInfo.init()
56         vodInfo.title       = "laOla-iOS-Test1"
57         vodInfo.desc        = ""
58         vodInfo.cateId      = 0
59         vodInfo.tags        = ""
60         
61         self.uploader?.addFile(videoPath, vodInfo: vodInfo)
62         self.uploader?.start()
63         
64     }



 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap