現在、私はAVAudioSessionを使用してiOSにオーディオを録音していますが、50分以上録音すると問題が発生します。 AVAudioPlayerを使用して50分を超える録画を再生することはできません。レコードオーディオファイルの最大制限はどのように取得できますか?
録音オーディオの最大限度は誰にも分かります。
現在、私はAVAudioSessionを使用してiOSにオーディオを録音していますが、50分以上録音すると問題が発生します。 AVAudioPlayerを使用して50分を超える録画を再生することはできません。レコードオーディオファイルの最大制限はどのように取得できますか?
録音オーディオの最大限度は誰にも分かります。
はあり何であるかを検索しようとつかまえることができるように、特定の秒数に限定するコードで見つけることができませんでしたiPhoneのレコードファイルに制限はありません。 しかし、アプリケーションドキュメントディレクトリに保存する前に。 iPhoneの空き容量を確認してから保存してください。ファイルが失われる可能性は低くなります。
以下のコードはiPhoneの空き容量を確認するためのものです。
-(uint64_t)getFreeDiskspace {
NSString *folderPath = [[NSBundle mainBundle] bundlePath];
NSArray *filesArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:folderPath error:nil];
NSEnumerator *filesEnumerator = [filesArray objectEnumerator];
NSString *fileName;
unsigned long long int fileSize = 0;
while (fileName = [filesEnumerator nextObject]) {
NSDictionary *fileDictionary = [[NSFileManager defaultManager] fileAttributesAtPath:[folderPath stringByAppendingPathComponent:fileName] traverseLink:YES];
fileSize += [fileDictionary fileSize];
}
NSLog(@"App size : %lld",fileSize);
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];
NSError *attributesError = nil;
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[paths lastObject] error:&attributesError];
NSLog(@"App Directory size %llu",[fileAttributes fileSize]);
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)), ((totalFreeSpace)));
} else {
NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", [error domain], (long)[error code]);
}
// NSLog(@"DISK SPACE %f",[self diskSpace]);
// NSLog(@"GET FREE SPACE %lld",[self getFreeSpace]);
return totalFreeSpace;
}
- (long long)getFreeSpace
{
long long freeSpace = 0.0f;
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
if (dictionary) {
NSNumber *fileSystemFreeSizeInBytes = [dictionary objectForKey: NSFileSystemFreeSize];
freeSpace = [fileSystemFreeSizeInBytes longLongValue];
} else {
//Handle error
NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", [error domain], (long)[error code]);
}
NSLog(@"Free Space %lli",freeSpace);
return (freeSpace);
}
私はそれが最大の限界だが、ここであなたが制限
はい。しかし、私は最大限が何であるか知りたい。 –
あなたはbruteforceを使って試してみることができます。私は –
を検索して見つけられませんでした。ありがとうございます:) –