我录制了一些文件,然后播放它:
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString *soundFilePath = [docsDir
stringByAppendingPathComponent:@"temp0.caf"];
//play
[[SimpleAudioEngine sharedEngine] preloadEffect:soundFilePath];
[[SimpleAudioEngine sharedEngine] playEffect:soundFilePath pitch:1.5f pan:0.0f gain:0.3f];它在第一次工作,但第二次它再次播放相同的文件,即使我已经录制了一些其他文件。
有什么帮助吗?
发布于 2012-05-20 19:43:44
也许你的音频引擎正在预加载这个效果,并保持这个预加载,试一下:
[[SimpleAudioEngine sharedEngine] preloadEffect:nil];
[[SimpleAudioEngine sharedEngine] preloadEffect:soundFilePath];
[[SimpleAudioEngine sharedEngine] playEffect:soundFilePath pitch:1.5f pan:0.0f gain:0.3f];另外,代码在何时何地被调用。它是以你的记录命名的,对吧?也许可以试试:
NSArray *dirPaths = nil;
NSString *docsDir = nil;在顶端。试试看,如果不起作用,我需要看看你的录音代码
发布于 2012-05-23 11:27:06
我认为发生的情况是您的音频文件拒绝被新文件覆盖。也许您应该尝试在每次用户记录一个文件时更改文件的名称。这样,当他录制时,您可以将文件保存为字符串,格式为:
[NSMutableString stringWithFormat:@"temp%d.caf",number];然后,每当用户想要记录时,您就将“number”加1。
number = number +1;https://stackoverflow.com/questions/10672959
复制相似问题