2012-02-16 255 views
1

我試圖記錄和saave MP3文件,所以我用下面的代碼記錄音頻文件爲MP3或WAV

NSString* d = @" ar/mobile/Applications/86F15C5E-66EC-4071-95EB-96CDE64B5948/Library/Application Support/P/5720/5720/Report/Report0.mp3" 

NSURL *soundFileURL = [NSURL fileURLWithPath:d]; 

NSDictionary *recordSettings = [NSDictionary 
           dictionaryWithObjectsAndKeys: 
           [NSNumber numberWithInt:AVAudioQualityMin], 
           AVEncoderAudioQualityKey, 
           [NSNumber numberWithInt:16], 
           AVEncoderBitRateKey, 
           [NSNumber numberWithInt: 2], 
           AVNumberOfChannelsKey, 
           [NSNumber numberWithFloat:44100.0], 
           AVSampleRateKey, 
           nil]; 

NSError *error = nil; 

audioRecorder = [[AVAudioRecorder alloc] 
        initWithURL:soundFileURL 
        settings:recordSettings 
        error:&error]; 

if (error) 
{ 
    NSLog(@"error: %@", [error localizedDescription]); 

} else { 
    [audioRecorder prepareToRecord]; 
} 

,並開始我使用記錄

[audioRecorder record]; 

的MP3我得到錯誤 錯誤:操作無法完成。 (OSStatus錯誤1718449215.)

,如果我保存爲WAV沒有被記錄,並且該文件是0字節

我失去的東西,任何想法如何解決

回答

0

也許它保存到文件夾?這不是正確的法律途徑嗎?

1

你不顯示Dpath的定義方式...

NSString * filePath = [NSHomeDirectory()stringByAppendingPathComponent: [NSString stringWithFormat:@"Documents/%@.mp3",songTitle]]; 

// more code  

recorder = [[AVAudioRecorder alloc] initWithURL: [NSURL fileURLWithPath:filePath settings: recordSettings error: nil]; 
+0

我更新的代碼 – AMH 2012-02-16 14:27:40

相關問題