【发布时间】:2011-01-25 08:46:41
【问题描述】:
- (IBAction)triggerSound {
if (player == nil) {
NSError *error;
player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
} else if ([player isPlaying]) {
[player stop];
player.currentTime = 0;
}
if (![player play]) {
NSLog(@"fail");
}
}
其中 player 是 AVAudioPlayer,此操作与 UIButton 链接。声音可以播放,声音结束后可以再次播放,但是在播放过程中再次按下按钮时,记录“失败”消息,无法播放声音,没有任何异常。
我在 iOS 4.2.1 上使用 iPad。
【问题讨论】:
标签: ios4 avaudioplayer