當用戶單擊按鈕時,我正在使用AVAudioPlayer播放小聲音。聲音持續約3秒鐘,我想要的是,如果用戶多次按下按鈕,該聲音應該會多次發聲。如果用戶在2秒內點擊兩次,則第二個聲音應該與第一個鏡頭重疊。在iOS中播放重疊聲音
我的問題是,鏡頭只發出每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?我應該使用另一個框架嗎?