2013-11-15 41 views
0

我想在UITableView中显示音频文件的大小。我记录的音频:如何确定录制的音频文件的大小

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error: nil]; 

[[AVAudioSession sharedInstance] setActive: YES error: nil]; 

NSDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys: 
           [NSNumber numberWithFloat: 44100.0], AVSampleRateKey, 
           [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, 
           [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, 
           [NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey, nil]; 

我保存在文件夹中的文件,我在一家UITableView细胞显示名称。

如何显示音频文件的大小?

回答

0

试试这个

NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:URL error:&attributesError]; 

NSNumber *fileSizeNumber = [fileAttributes objectForKey:NSFileSize]; 
long long fileSize = [fileSizeNumber longLongValue]; 

注意,档案大小并不一定适合在一个整数(尤其是签署一个),虽然你当然可以下降到很长的iOS,你永远也不会超过在现实中。该示例使用很长时间,因为在我的代码中,我必须与具有更大存储空间的系统兼容。

相关问题