AVFoundation 프레임 워크를 사용하여 많은 양의 단추가있는 "대화 형 인터뷰"사운드 보드를 만들려고합니다. 사운드 보드가 완료되었지만 하나의 문제가 있습니다. 새 사운드를 누를 때 멈추지 않습니다. 새 소리가 들리면 이전 소리를 멈추는 쉬운 방법이 있습니까? 여전히 재생중인 경우 내 코드, 난 그냥 내 수업이 마지막으로 시작 소리의 추적이 있고, 나는 새로운 사운드를 연주하기 시작하기 전에, 이전을 중지 할이AVAudioPlayer를 사용하여 사운드를 어떻게 풀 수 있습니까?
- (IBAction)playSound0 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}
- (IBAction)playSound1 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"chillwhatup" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}
- (IBAction)playSound2 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"gethighorgetlow" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}
- (IBAction)playSound3 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"icamefromthere" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}
- (IBAction)playSound4 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"idoeverythinggood" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}
이것은 Xcode와 관련이 없습니다. 또한 "Xcode"와 ** ** "XCODE", "xCode", "XCode"또는 그 밖의 철자가 없습니다. 철자 및 용어를 이미 배우십시오! –