2016-06-24 7 views
2

은 동영상을 녹화하는 동안 기기 저장 용량이 거의 가득 찬 경우 알림을받을 수있는 방법입니다. 아이폰의 저장 용량이 얼마 남지 않으면 어떻게 녹화를 중단 할 수 있습니까?

은 내가 AVCaptureMovieFileOutput을 사용하지만 비디오 프레임은 비디오 파일에 저장되기 전에 일부 비디오 조작을 할 필요가 있기 때문에 불행히도 나는이를 사용하지 못할 경우 녹음의 maxRecordedFileSize 를 설정할 수있는 것을 발견했다.

대신에 AVCaptureVideoDataOutputAVAssetWriter으로 접근해야합니다.

저장 용량이 가득 찼을 때 알리는 일종의 시스템 알림을 볼 수 있습니까?

답변

1

당신은 디스크

-(uint64_t)getFreeDiskspace{ 
    uint64_t totalSpace = 0.0f; 
    uint64_t totalFreeSpace = 0.0f; 
    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 floatValue]; 
     totalFreeSpace = [freeFileSystemSizeInBytes floatValue]; 
     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 = %@, Code = %@", [error domain], [error description]); 
    } 

    return totalFreeSpace; 
} 

에서 사용 가능한 공간을 얻기 위해 다음 코드를 사용할 수 있으며

if([self getFreeDiskspace]>100.0){ 
    //The store 
}else{ 
    //Alert user 
} 

는 희망이 도움이처럼 확인할 수 있습니다.

+0

테스트를 마치면 테스트 해 보겠습니다. 감사 –