0

I have encountered this problem where the device has not enough space to save a video file which is present in the NSDocumentsDirectory, to the photo library.

The problem is, UISaveVideoAtPathToSavedPhotosAlbum does not throw any error while saving it.

UISaveVideoAtPathToSavedPhotosAlbum(session.outputURL.path, self, @selector (video:didFinishSavingWithError:contextInfo:), nil); //session is AVAssetExportSession


- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];

    if(error) //else part is executed every time...
    {
        ALERT_WITH_MESSAGE([@"Your composition could not be saved to your device library. Error: " stringByAppendingString:error.description]);
    }

    else
    {
        ALERT_WITH_MESSAGE(@"Your composition has been saved to your device library.");
    }
}
nr5
  • 4,228
  • 8
  • 42
  • 82
  • First check whether there are enough space available in your device or not, if yes then only start downloading otherwise not required. if(freeSpace > downlaodSize) then only. – Mrunal Sep 17 '14 at 10:49
  • I have used the code from this link (http://aasims.wordpress.com/2012/02/14/how-to-find-available-disk-space-of-ios-device/) to determine the freespace on my device. Sadly, the device showed 12.2 mb left and the code says 222 mb. – nr5 Sep 17 '14 at 12:03
  • Check http://stackoverflow.com/questions/5310445/check-enough-space-on-iphone-device-before-downloading-files freeSpace = [fileSystemFreeSizeInBytes longValue]; – ares777 Sep 17 '14 at 12:22
  • same result, code says 200 mb free but my device Settings > Usage shows 12.2 mb – nr5 Sep 18 '14 at 04:53
  • This is madness, UISaveVideoAtPathToSavedPhotosAlbum should throw an error :( – nr5 Sep 18 '14 at 04:54

1 Answers1

-3

If you mean the ALERT_WITH_MESSAGE it is not displayed, try to comment [MBProgressHUD hideHUDForView:self.view animated:YES]; or add some delay ... {somethimes this HUD is treated as an alert itself}

ares777
  • 3,590
  • 1
  • 22
  • 23
  • The user said that no error is thrown and not about alert showing. – nikhil84 Sep 17 '14 at 11:20
  • Read the code. if(error) -> show alert . So this is why I asked for alert being displayed. You downvoted fast :D Nevermind. .in =)) – ares777 Sep 17 '14 at 11:21
  • I have read the query it like this "if(error) //else part is executed every time..." so the person said that else part was being executed which implies that no error(as execution was going into else part and not if part) – nikhil84 Sep 17 '14 at 11:29