当应用程序进入后台模式时,AVAssetExportSession将停止

时间:2018-03-18 01:29:31

标签: ios swift

我正在尝试合并一堆音频文件,然后将它们导出到一个文件中。它在应用程序处于活动状态时工作正常,但是当我离开应用程序时(通过按主页按钮,转到另一个应用程序等),它会完全停止。当我返回应用程序时,进度不会继续,我必须重新启动导出。关于如何让exportSession在后台模式下继续的任何想法?

self.assetExport = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetAppleM4A)
self.assetExport?.outputFileType = AVFileTypeAppleM4A
self.assetExport?.outputURL = self.fileDestinationUrl
self.assetExport?.exportAsynchronously(completionHandler: {

    switch self.assetExport!.status {
    case AVAssetExportSessionStatus.failed:
        print("failed \(self.assetExport?.error)")
    case AVAssetExportSessionStatus.cancelled:
        print("cancelled \(self.assetExport?.error)")
    case AVAssetExportSessionStatus.unknown:
        print("unknown\(self.assetExport?.error)")
    case AVAssetExportSessionStatus.waiting:
        print("waiting\(self.assetExport?.error)")
    case AVAssetExportSessionStatus.exporting:
        print("exporting\(self.assetExport?.error)")
    default:
        print("complete")
        self.exportProgress.invalidate()

        completion()
    }

})

0 个答案:

没有答案