iOS:使用URLSessionDownloadDelegate下载大视频时出现问题。超过40mb时停止

时间:2018-10-29 10:49:57

标签: ios swift nsurlsession nsurlsessiondownloadtask urlsession

我使用的是SDK(YITechnology),但下载超过40mb的视频时遇到了问题。当我在ViewController中使用该代码时,小于40mb的视频就可以了。问题是,如果它们大于40mb,它将停止。我如何告诉它继续下载? 我尝试过ticket,但这不是完全一样的事情...

ActionCamera:

@objc public class ActionCamera : NSObject, URLSessionDownloadDelegate {
public func downloadFile(fileName: String, destFilePath: String, success: ((YICameraSDK.DownloadTask) -> ())?, fail: ((Error) -> ())?) -> YICameraSDK.ActionCamera

    /// Cancel current download task.
    public func cancelDownlad() -> YICameraSDK.ActionCamera

     /// Download file from camera.
///
/// - Parameters:
///     - fileName: The file you want to download from camera.
///     - destFilePath: The file destination file path. Need to be a full path.
///     - success: This callback will be invoked multiple times to notify the progress.
///     - fail: This callback will be invoked if download failed.
public func downloadFile(fileName: String, destFilePath: String, success: ((YICameraSDK.DownloadTask) -> ())?, fail: ((Error) -> ())?) -> YICameraSDK.ActionCamera


    public func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL)

    public func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64)

    public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?)
}

ViewController.swift:

private var mCamera: ActionCamera!;

self.mCamera.downloadFile(fileName: lastFileName, destFilePath: originPath, success:
            {
                downloadTask in
                self.testLbl.text = String(describing: downloadTask.downloadedBytes)



        } , fail: {
            error in

            let alert = UIAlertView();
            alert.message = error as? String;
            alert.addButton(withTitle: "Ko")
            alert.show()
        });

我认为对于熟悉UrlSession的人来说这很容易,但这不是我的情况...

0 个答案:

没有答案