你能告訴我如何解決這個問題嗎?我想在他們完成比賽時發佈兩個不同的AVAudioPlayer
,但分開。不能使用兩個「audioPlayerDidFinishPlaying」
這裏是我的代碼:
.h文件中
@interface ViewController : UIViewController <AVAudioPlayerDelegate>
{
NSString *path;
}
- (IBAction)Short:(id)sender;
- (IBAction)BeatLong:(id)sender;
.m文件
AVAudioPlayer *media;
AVAudioPlayer *media2;
- (IBAction)Short:(id)sender
{
path = [[NSBundle mainBundle] pathForResource:@"Short" ofType:@"wav"];
media = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[media setDelegate:self];
[media play];
}
- (IBAction)Beat:(id)sender
{
path = [[NSBundle mainBundle] pathForResource:@"Beat" ofType:@"mp3"];
media2 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[media2 setDelegate:self];
[media2 play];
}
(在新的T打開圖片AB看到它更好^^)
我已經添加了更多的代碼:-) – Aluminum