0
我是Objective-C中的新成員。請幫助我。 我有一個viewController包含scrollview。 scrollView是分頁啓用,所以我有10頁在每頁我有30個按鈕。 我的問題是,當點擊按鈕多我要玩多個聲音..點擊多個UIButton如何在同一時間播放多個聲音?
我的代碼: -
-(void)buttonClicked:(UIButton *)sender{
if (sender.tag == 1) {
NSString *audioPath = [[NSBundle mainBundle]pathForResource:@"v1" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:audioPath];
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil];
audioPlayer.delegate = self;
[audioPlayer play];
}
if (sender.tag == 2) {
NSString *audioPath = [[NSBundle mainBundle]pathForResource:@"v2" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:audioPath];
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil];
audioPlayer.delegate = self;
[audioPlayer play];
}
if (sender.tag == 3) {
NSString *audioPath = [[NSBundle mainBundle]pathForResource:@"v3" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:audioPath];
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil];
audioPlayer.delegate = self;
[audioPlayer play];
}
問題是,當我按下按鈕上只有一個聲音啓用。如何啓用多個聲音? 請幫我... 由於事先
上面的代碼有什麼問題? – Apurv
你還沒有描述你的問題。當你按下多個按鈕時發生了什麼? –
@Agent不,我想混合多種音頻聲音。 – Vishal16