|
@@ -46,6 +46,11 @@ class PublishUploadManager: NSObject {
|
|
|
var imageUrlArray: Array<String> = []
|
|
|
|
|
|
var uploadManager: AlivcShortVideoUploadManager?
|
|
|
+
|
|
|
+
|
|
|
+ var progressView: PublishUploadProgressView?
|
|
|
+ // 记录当前是否发布完成
|
|
|
+ var isPublishFinished: Bool = true
|
|
|
}
|
|
|
|
|
|
// MARK: - 视频上传流程
|
|
@@ -61,6 +66,7 @@ extension PublishUploadManager: AlivcShortVideoUploadManagerDelegate {
|
|
|
|
|
|
// 获取上传地址和凭证
|
|
|
func communityVideoUploadAuthApi() {
|
|
|
+ isPublishFinished = false
|
|
|
|
|
|
var vTitle: String = ""
|
|
|
if videoPath.count > 20 {
|
|
@@ -94,6 +100,8 @@ extension PublishUploadManager: AlivcShortVideoUploadManagerDelegate {
|
|
|
DispatchQueue.main.async(execute: {
|
|
|
print("\n--------uploadProgress == \(progress)")
|
|
|
// self.progressView.progress = Float(progress)
|
|
|
+
|
|
|
+ self.progressView?.uploadProgress = Float(progress)
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -122,6 +130,7 @@ extension PublishUploadManager: AlivcShortVideoUploadManagerDelegate {
|
|
|
self?.majorImageUrl = imgUrl as? String
|
|
|
|
|
|
print("------视频上传成功,去发布")
|
|
|
+ self?.progressView?.curUploadStatus = .success
|
|
|
self?.communityPublishApi()
|
|
|
}
|
|
|
}
|
|
@@ -138,6 +147,7 @@ extension PublishUploadManager {
|
|
|
|
|
|
// 上传图片
|
|
|
func uploadAllImages(totalTimes: Int) {
|
|
|
+ isPublishFinished = false
|
|
|
|
|
|
var curTimes: Int = totalTimes
|
|
|
|
|
@@ -156,15 +166,17 @@ extension PublishUploadManager {
|
|
|
// 更新进度
|
|
|
DispatchQueue.main.async {
|
|
|
print("----\(Thread.current)")
|
|
|
- print("----uploadImgProgress == \(curTimes/(self?.imageArr!.count)!)")
|
|
|
+ print("----uploadProgress == \(Float(curTimes)/Float((self?.imageArr!.count)!))")
|
|
|
+
|
|
|
+ self?.progressView?.uploadProgress = Float(curTimes/(self?.imageArr!.count)!)
|
|
|
|
|
|
}
|
|
|
|
|
|
if curTimes < self?.imageArr?.count ?? 0 {
|
|
|
self?.uploadAllImages(totalTimes: curTimes)
|
|
|
} else {
|
|
|
- // FIXME: 图片上传成功,去发布
|
|
|
print("------图片上传成功,去发布")
|
|
|
+ self?.progressView?.curUploadStatus = .success
|
|
|
self?.communityPublishApi()
|
|
|
}
|
|
|
}
|
|
@@ -215,5 +227,9 @@ extension PublishUploadManager {
|
|
|
VirusViewModel.shared.publishVirueRecordAddApi(postId: pubModel.postId, postType: typeStr, title: pubTitle, content: pubContent, postCover: majorImageUrl)
|
|
|
|
|
|
print("\n----------发布成功!!!!!")
|
|
|
+ isPublishFinished = true
|
|
|
+// progressView?.hide()
|
|
|
+
|
|
|
+ progressView?.curUploadStatus = UploadStatus.failure
|
|
|
}
|
|
|
}
|