I cannot get AVAssetExportSession to work when the application is in the background.
My application has the Background Mode "Background Fetch" enabled.
When this UIApplicationDelegate method is called
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
is called I use AVAssetExportSession to export an AVAsset, using the method:
exportAsynchronouslyWithCompletionHandler
I then receive this error:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x147dae560 {Error Domain=NSOSStatusErrorDomain Code=-16980 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16980), NSLocalizedDescription=The operation could not be completed}
However, when I have the background mode "Audio, Airplay and Picture in Picture", the export works.
This is great, however our submission is being rejected because we do not play any audio in the background.
is there any other way to export video in the background?
Cheers, Red
STEPS TO REPRODUCE I have created a sample project to show this issue.
Download from: http://up.red.to/WKo1MMstzD
- Run the app on a device
- Accept the permissions
- Press the home button
- In Xcode, go to Debug -> Simulate Background Refresh
- See error (printed in console and shown as a local notification)