AVAssetWriter fails once App goes in background

I am working on iOS app in which i am creating video from images. I am using AVAssetWriter to achieve this. Everything works fine. But When app goes in background and switched back, the video writing fails. AVAssetWriter's finishWritingWithCompletionHandler is not getting called when i switch back to app.

May be duplicate of AVAssetWriter fails when Application enters Background during Rendering , but i am not getting any help from there.

Any idea for this?

Thanks

Answers


This answer is based on the assumption that you want the video to continue rendering while in the background.

I fixed this in my app doing by asking the OS to grant the app background task permisions (for a limited amount of time). This answer might help you too iOS generating a video in the background task

    @property (nonatomic,assign) UIBackgroundTaskIdentifier __block backgroundRenderingID;

    UIApplication *app = [UIApplication sharedApplication];

    _backgroundRenderingID = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:_backgroundRenderingID];
        _backgroundRenderingID = UIBackgroundTaskInvalid;
    }];

Don't forget to let go once you are done!

[[UIApplication sharedApplication] endBackgroundTask:_backgroundRenderingID];

Need Your Help

Laravel 4 belongsToMany Relationship Returns Empty

php laravel many-to-many relationship

I'm using Laravel 4, and I'm struggling to set up a many to many relationships. Here's an example of what I'm trying to do. Here, I'm trying to establish a many to many relationship between a User ...

Using makefiles and vim without prompt

vim makefile

I'm using vim and im doing a lot of

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.