我正在写一个只有100kb大小的视频。我的手机在磁盘上剩下大约20mb,但是当我尝试使用AVFoundation和AVCaptureMovieFileOutput创建录制时,我收到错误:
2014-06-15 10:40:19.511 wave[551:690b] ERROR:
Error Domain=AVFoundationErrorDomain
Code=-11807 "Operation Stopped" UserInfo=0x157cde20
{NSLocalizedRecoverySuggestion=There
is not enough available space to continue the file writing.
Make room by deleting existing videos or photos
我正在设置
self.movieFileOutput.minFreeDiskSpaceLimit = //space available in bytes
认为它会覆盖这种默认行为,但事实并非如此。知道如何在给定磁盘空间参数的情况下继续允许记录吗?
更新 - 这是我用来获得可用空间的代码:
-(uint64_t)getFreeDiskspace {
uint64_t totalSpace = 0;
uint64_t totalFreeSpace = 0;
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
if (dictionary) {
NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
NSLog(@"Memory Capacity of %llu MiB with %llu MiB Free memory available.", ((totalSpace/1024ll)/1024ll), ((totalFreeSpace/1024ll)/1024ll));
} else {
NSLog(@"Error Obtaining System Memory Info: Domain = %@", error);
}
return totalFreeSpace;
}