rs / SDAVAssetExportSession

AVAssetExportSession drop-in replacement with customizable audio&video settings
MIT License
805 stars 212 forks source link

Export video in background #8

Closed Sashom closed 7 years ago

Sashom commented 10 years ago

Hi, is there a way to make this work (at least in the allowed 3 minutes) in the background in case I hit the home button while export is being made?

mikezucc commented 9 years ago

Have the app delegate maintain a strong reference to the SD object?

bcattle commented 8 years ago

You do this by calling beginBackgroundTaskWithExporationHandler:, for example:

if ([[UIDevice currentDevice] isMultitaskingSupported]) {
    self.backgroundRecordingID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
            // If the task expires, just end it to avoid having the app terminated
            [[UIApplication sharedApplication] endBackgroundTask:self.backgroundRecordingID];
            self.backgroundRecordingID = UIBackgroundTaskInvalid;
            NSLog(@"ERROR: recording background task timed out");
        }];
}
bcattle commented 8 years ago

Eh there should probably be a weakSelf in there, but you get the idea