【发布时间】:2014-10-16 13:57:16
【问题描述】:
当用户单击按钮时,我正在使用 AVAudioPlayer 播放一点射击声音。声音持续约 3 秒,我希望,如果用户多次按下按钮,则该镜头应该发出多次声音。如果用户在 2 秒内点击了两次,那么第二个声音应该与第一个镜头重叠。
我的问题是每 3 秒(如果用户快速单击),而不是每次按下按钮时才发出一次声音。
ViewDidLoad 内部
NSString *path = [[NSBundle mainBundle] pathForResource:@"shot" ofType:@"caf"];
urlShotCaf = [NSURL fileURLWithPath:path];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:urlShotCaf error:nil] ;
[player prepareToPlay];
当一个人点击拍摄按钮时
- (IBAction)tap:(id)sender {
clicks++;
[player play];
}
我可以用 AVAudioPlayer 做到这一点吗?我应该使用其他框架吗?
【问题讨论】:
标签: iphone objective-c