【发布时间】:2011-04-17 07:45:18
【问题描述】:
我正在尝试使用 AVAudioPlayer 在 iPhone 和 iPod touch 上播放音频文件。该代码在 iPhone 和 iPod touch 4G 中运行良好,我可以听到音乐。但是当我在 iPod touch 2G、iPod touch 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];
【问题讨论】:
标签: ios avaudioplayer ipod-touch