ios - 如何获得录制音频文件的最大限制?
<p><p>目前我正在使用 AVAudioSession 在 iOS 中录制音频,但录制超过 50 分钟时会出现问题。使用 AVAudioPlayer 无法播放超过 50 分钟的重新编码。</p>
<p>谁能告诉录制音频的最大限制是多少。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>iPhone 中的录音文件没有限制。
但在保存到应用程序文档目录之前。检查 iPhone 上的可用空间,然后保存,这样丢失文件的机会就会减少。</p>
<p>以下代码用于检查 iPhone 中的可用空间。</p>
<pre><code>-(uint64_t)getFreeDiskspace {
NSString *folderPath = [ bundlePath];
NSArray *filesArray = [ subpathsOfDirectoryAtPath:folderPath error:nil];
NSEnumerator *filesEnumerator = ;
NSString *fileName;
unsigned long long int fileSize = 0;
while (fileName = ) {
NSDictionary *fileDictionary = [ fileAttributesAtPath: traverseLink:YES];
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 = [ attributesOfFileSystemForPath: error: &error];
NSError *attributesError = nil;
NSDictionary *fileAttributes = [ attributesOfItemAtPath: error:&attributesError];
NSLog(@"App Directory size %llu",);
if (dictionary) {
NSNumber *fileSystemSizeInBytes = ;
NSNumber *freeFileSystemSizeInBytes = ;
totalSpace = ;
totalFreeSpace = ;
NSLog(@"Memory Capacity of %llu MiB with %llu MiB Free memory available.", ((totalSpace)), ((totalFreeSpace)));
} else {
NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", , (long));
}
// NSLog(@"DISK SPACE %f",);
// NSLog(@"GET FREE SPACE %lld",);
return totalFreeSpace;
}
- (long long)getFreeSpace
{
long long freeSpace = 0.0f;
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [ attributesOfFileSystemForPath: error: &error];
if (dictionary) {
NSNumber *fileSystemFreeSizeInBytes = ;
freeSpace = ;
} else {
//Handle error
NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", , (long));
}
NSLog(@"Free Space %lli",freeSpace);
return (freeSpace);
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何获得录制音频文件的最大限制?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/38024843/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/38024843/
</a>
</p>
页:
[1]