Danie1s / Tiercel

简单易用、功能丰富的纯 Swift 下载框架
MIT License
2.67k stars 388 forks source link

下载单个视频,进度一直是0 #192

Closed moo611 closed 1 year ago

moo611 commented 1 year ago

image

在success和fail也没收到回调

singleDownloadManager.progress{manager in

            print("下载中, 进度:\(manager.progress.fractionCompleted)")
            ProgressHUD.showProgress(manager.progress.fractionCompleted,interaction: true)
        }.success{manager in
            print("下载完成")

            let fileName = manager.tasks[0].fileName
            print("file name is:\(fileName)")

            self.isDownloading = false
            ProgressHUD.dismiss()
            manager.totalRemove()
            self.view.makeToast(NSLocalizedString("save_success", comment: ""))
        }.failure{manager in
            print("下载失败")
            self.isDownloading = false
            manager.totalRemove()
            ProgressHUD.dismiss()
            self.view.makeToast(NSLocalizedString("download_fail", comment: ""))
        }
moo611 commented 1 year ago

视频url(超过1天会过期,但是我测试的时候是可以在浏览器访问的) https://scontent.cdninstagram.com/v/t50.2886-16/322926394_533176092097466_4046620750502107347_n.mp4?_nc_ht=scontent.cdninstagram.com&_nc_cat=102&_nc_ohc=8Q0J8uikMRMAX_zdjGR&edm=AJBgZrYBAAAA&ccb=7-5&oh=00_AfDRZPw1Yz2NnwzN_TICr0XCf6n0tej9-c0gmWP4MxD1_w&oe=63C19DE1&_nc_sid=78c662

Danie1s commented 1 year ago

我用 demo 测试是可以下载,文件可以播放的

moo611 commented 1 year ago

请问如果链接超时了,会走failure吗?

moo611 commented 1 year ago

我现在偶尔会遇到这种卡着的情况,想看看没有什么好的解决方案。

moo611 commented 1 year ago

@Danie1s 不好意思,我在公司是在wify下测试的没问题,在家里用的是4g会出现上述情况。看其他人的答案我把配置设成configuration.allowsCellularAccess = true 就好了。