Ios AVExportSession将在后台继续
我正在开发一个需要合并多个视频的应用程序。我正在使用AVExportSession导出合并视频。我还显示了用于导出视频的进度条。它运行正常 当我们锁定屏幕或将应用程序置于后台模式时,问题就会出现。这一次,如果正在导出,则将应用程序置于后台模式后会立即失败。 我也尝试过使用后台任务。检查下面的代码Ios AVExportSession将在后台继续,ios,video,avassetexportsession,avmutablecomposition,avasset,Ios,Video,Avassetexportsession,Avmutablecomposition,Avasset,我正在开发一个需要合并多个视频的应用程序。我正在使用AVExportSession导出合并视频。我还显示了用于导出视频的进度条。它运行正常 当我们锁定屏幕或将应用程序置于后台模式时,问题就会出现。这一次,如果正在导出,则将应用程序置于后台模式后会立即失败。 我也尝试过使用后台任务。检查下面的代码 if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) { if ([[UI
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) {
if ([[UIDevice currentDevice] isMultitaskingSupported]) {
UIApplication *application = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier background_task; /
background_task = [application beginBackgroundTaskWithExpirationHandler: ^ {
[application endBackgroundTask: background_task];
background_task = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//START EXPORT SESSION
[exporter exportAsynchronouslyWithCompletionHandler:^
{
dispatch_async(dispatch_get_main_queue(), ^{
[self exportDidFinish:exporter];
});
}];
NSLog(@"Running in the background!");
[application endBackgroundTask: background_task];
background_task = UIBackgroundTaskInvalid;
});
}
}
但这似乎不起作用。我做错了什么?任何帮助都将不胜感激
我知道可以在后台运行AVExportSession,因为我在应用商店中发现了许多可以这样做的应用程序
提前感谢。将此代码替换为
[自导出完成:导出器]代码>
[self performSelectorOnMainThread:@selector(exportDidFinish:) withObject:exporter waitUntilDone:YES];
背景代码以什么方式不起作用?它仍然失败吗?您会收到什么错误?当我从后台返回时,将调用exportdidfinish方法,其中我将使用if语句跟踪导出状态,并调用exporter.status==AVAssetExportSessionStatusFailed。没有错误,导出只是停止。我现在意识到,我提到的其他程序不是在后台继续,而是在某种程度上暂停导出,并在返回前台时继续。我不知道你是如何暂停exportsession的。你有没有想过这个问题?我想做同样的事情,但也失败了。这对我来说没什么区别。当我进入后台时,导出停止,当我进入前台时,将使用AVAssetExportSessionStatusFailed调用exportdidfinish方法