AVQueuePlayer
을 사용하여 사운드를 재생할 수없는 것 같습니다. 응용 프로그램을 컴파일하고 잘 실행되지만`imageTouched '메서드가 호출 될 때 오디오가 표시되지 않습니다. 누구든지 도와 줄 수 있습니까?AVQueuePlayer가 사운드를 재생하지 않습니다.
-(void) imageTouched
{
NSString * path1 = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"wav"];
NSString * path2 = [[NSBundle mainBundle] pathForResource:@"sound2" ofType:@"wav"];
NSURL *url1 = [NSURL fileURLWithPath:path1];
NSURL *url2 = [NSURL fileURLWithPath:path2];
AVPlayerItem *firstSound = [AVPlayerItem playerItemWithURL:url1];
AVPlayerItem *secondSound = [AVPlayerItem playerItemWithURL:url2];
NSArray *sounds = [NSArray arrayWithObjects:firstSound, secondSound, nil];
AVQueuePlayer *player = [AVQueuePlayer queuePlayerWithItems:sounds];
[player play];
NSLog(@"%d",player.status);
}
편집 1 : 나는 파일 이름 (대소 문자, 철자, 등)에 문제가 있었고이있을 것 같지 않습니다 있는지 확인했습니다. 다음 코드를 사용하여 사운드를 재생할 수 있었지만 실제로는 AVQueuePlayer
이 필요합니다. 도와주세요!
NSString *path;
SystemSoundID soundId;
path = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"wav"];
NSURL *url = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID((CFURLRef)objc_unretainedPointer(url), &soundId);
AudioServicesPlaySystemSound(soundId);
사운드 파일이 실제로 앱 번들에 포함되어 있고 파일 이름의 철자가 올바른지 (대소 문자 포함) 확인하십시오. – hotpaw2
소리가 내 리소스 폴더에 복사되고 맞춤법이 정확합니다. 불행히도 그것은 문제가 아닙니다. 내 nslog는 어떤 도움이 있다면 0을 출력하고 있습니다. – garethdn
'AudioServicesPlaySystemSound (soundId);를 사용하여 사운드를 잘 재생할 수 있다고 언급해야하지만'AVQueuePlayer'를 사용하고 싶습니다. 아마 내가 .h 파일에서 누락 된 것이 있습니까? – garethdn