我试图在iPhone和iPod touch上播放音频文件,其中包括AVAudioPlayer。该代码工作正常iPhone和iPod touch 4G,我可以听到音乐。但是当我测试它iPod touch 2G,iPod touch 3G,我什么都听不到。AVAudioPlayer在iPod touch 2G和3G中播放音乐
下面是我用它来播放音频文件的代码:
NSString *zeroAudioPath = [[NSBundle mainBundle] pathForResource:@"TimerBell"
ofType:@"aif"];
NSURL *file = [[NSURL alloc] initFileURLWithPath:zeroAudioPath];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:file
error:nil];
[file release];
self.zeroAudioPlayer = audioPlayer;
zeroAudioPlayer.delegate = self;
[audioPlayer release];
[zeroAudioPlayer prepareToPlay];
[zeroAudioPlayer play];