2013-11-15 90 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,你永遠也不會超過在現實中。該示例使用很長時間,因爲在我的代碼中,我必須與具有更大存儲空間的系統兼容。

相關問題