1

我正在使用 CDSoundEngine 录制声音并将它们保存在用户 /Documents/ 目录中。它工作正常......如果我去 iPad 模拟器的图书馆,声音就在那里......

我的问题是他们不玩。如果我将声音文件复制到项目中,它就会播放。

我错过了什么?

 -(void) playRecording {

 //alternative approach
 //NSString *filePath = [NSURL fileURLWithPath: recorderFilePath];

 NSURL *url = [NSURL fileURLWithPath: recorderFilePath];
 NSString *filePath = [url absoluteString];

 CCLOG(@"Playing the recorded audio ... %@",filePath); //correctly displays the path (with %20 for spaces) to /Documents/recording.caf

 CDSoundEngine *sse = [[CDAudioManager sharedManager] soundEngine];

 //[sse loadBuffer:1 filePath:@"recording.caf"]; //this works if the file is added to the main project

 [sse loadBuffer:1 filePath:filePath]; //this does not work

 //[sse loadBuffer:1 filePath:@"filePath"]; //this does not work

 [sse playSound:1 sourceGroupId: 0 pitch: 2.0f pan: 0.0f gain: 1.0f loop: NO];

 }
4

0 回答 0