播放.caf文件:在模拟器中工作正常但在iPhone中没有 [英] playing a .caf file: works fine in simulator but not in iPhone
问题描述
我正在制作录音机。重新编码和播放在模拟器上工作正常。但在iPhone上它不起作用。 (我按照 iPhoneOSPrmingmingGuide / AudioandVideoTechnologies )
I'm building a voice recorder. Recoding and playing works fine on simulator. But on iphone it doesn't work. (I followed the exact steps as mentioned in iPhoneOSProgrammingGuide/AudioandVideoTechnologies)
printf("%s(player)\n",[[self.soundFileURL absoluteString] UTF8String]);
AVAudioPlayer *newPlayer =
[[AVAudioPlayer alloc] initWithContentsOfURL: self.soundFileURL error: nil];
if([self.soundFileURL isFileURL]){
printf("isFileURL\n");
}
self.player = newPlayer;
[newPlayer release];
[player prepareToPlay];
[player setDelegate: self];
//recorderLabel.text=@"Playing..";
[player play];
printf("playing..\n");
调试器输出为
file:// localhost / var / mobile / Applications / 9A607A45-974B-4E9F-9839-FD21B3BC9DD8 / Documents / 1251828741.caf(player)
isFileURL
play ..
The debugger out put is file://localhost/var/mobile/Applications/9A607A45-974B-4E9F-9839-FD21B3BC9DD8/Documents/1251828741.caf(player) isFileURL playing..
推荐答案
iPhone的.caf文件需要编码为单声道,而不是立体声频道,只能用于iPhone。
.caf file for iPhone need to be encoded as a mono channel and not with a stereo channel then only it will work with iPhone.
这篇关于播放.caf文件:在模拟器中工作正常但在iPhone中没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!