아래에 여러 개의 AVAudioPlayers를 구현할 때 앱이 충돌합니다. 여러 AVAudioPlayer를 사용하여 여러 오디오 파일을 동시에 재생할 계획입니다. 사용자가 시작한 이벤트에 의해 트리거됩니다. ARC를 처음 사용하고 있는데, ARC가 AVAudioPlayers 설정에 적용될 수있는 방법에 대한 많은 문서는 없습니다 (Apple의 샘플 코드는 ARC 사전이며, 대부분의 자습서에서 찾을 수 있습니다).ARC
응용 프로그램이 하나의 AVAudioPlayer 인스턴스에서 제대로 작동하지만 초를 추가하면 SIGABRT가 throw됩니다. 내 생각 엔 ARC가 조기에 공개하는 플레이어 인스턴스와 관련이 있지만이를 방지 할 방법이 확실하지 않다는 것입니다. 다음과 같이
코드는 다음과 같습니다 (있는 viewDidLoad에서)
@interface LocationTracker : UIViewController <AVAudioPlayerDelegate> {
AVAudioPlayer *mainLoopPlayer;
AVAudioPlayer *sea1Player;
}
@property (strong, nonatomic) AVAudioPlayer *mainLoopPlayer;
@property (strong, nonatomic) AVAudioPlayer *sea1Player;
@end
구현 :
NSURL *mainLoopURL = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:@"wind" ofType:@"aiff"]];
self.mainLoopPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:mainLoopURL error:nil];
mainLoopPlayer.numberOfLoops = -1;
mainLoopPlayer.delegate = self;
[mainLoopPlayer prepareToPlay];
NSURL *sea1URL = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:@"sea1" ofType:@"aiff"]];
self.sea1Player = [[AVAudioPlayer alloc] initWithContentsOfURL:sea1URL error:nil];
sea1Player.numberOfLoops = -1;
sea1Player.delegate = self;
[mainLoopPlayer prepareToPlay];
어떤 도움이 많이 감사합니다.
디버거를 거치면서 NSURL 인스턴스에 문제가있는 것처럼 보입니다. 그들이 사용되기 전에 풀려나거나 다른 하나와 충돌하고 있습니까? – MightyMeta