.caf 오디오 파일을 재생하는 코드를 사용합니다. 동일한 코드가 iPhone 4s 및 iPad 2에서는 잘 작동하지만 iPhone 5에서는 전혀 재생되지 않습니다. . 오디오 파일이 iPhone 5에서 재생되지 않습니다.
이
코드입니다 :-(IBAction)checkSound:(id)sender
{
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Lunatic.caf", [[NSBundle mainBundle] resourcePath]]];
NSLog(@"%@",url);
NSError *error;
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
self.audioPlayer.numberOfLoops = 0;
self.audioPlayer.volume = 1;
NSLog(@"log audioplayer: %@",audioPlayer);
if (audioPlayer != nil)
{
[self.audioPlayer prepareToPlay];
[self.audioPlayer play];
}
if (audioPlayer.playing == NO)
{
NSLog(@"not playing, error: %@",error);
}
if([[NSFileManager defaultManager] fileExistsAtPath:@"file://localhost/var/mobile/Applications/0D3F5169-8DB1-4398-A09A-DB2FBADF57EF/myApp.app/Lunatic.caf"])
{
NSLog(@"file exist");
}
else
{
NSLog(@"file doesn't exist");
}
}
이 로그 출력 :
2013-08-07 20:05:52.694 myApp[7006:907] file://localhost/var/mobile/Applications/0D3F5169-8DB1-4398-A09A-DB2FBADF57EF/myApp.app/Lunatic.caf 2013-08-07 20:05:52.697 myApp[7006:907] log audioplayer: (null) 2013-08-07 20:05:52.701 myApp[7006:907] not playing, error: Error Domain=NSOSStatusErrorDomain Code=-43 "The operation couldn’t be completed. (OSStatus error -43.)" 2013-08-07 20:05:52.703 myApp[7006:907] file doesn't exist
당신이 audioplayer 로그가 "널 (null)"제공 및 오류 로그에 오류가 -43라고 볼 수 있듯이 .... 하지만 반복 ... 아이폰과 함께 4s 다 잘 작동합니다 ....
실마리가 왜 이런 일이 발생합니까? iPhone 5에서 오디오로 무언가를 바꿨습니까? 내 iPhone 5의 사운드가 재생되는 것을 방해하는 설정 일 수 있습니까? 도움을 주시면 감사하겠습니다.
I 추가 tryed [audioPlayer prepareToPlay] audioplayer를 호출하기 전에 ...하지만 아무 일도 일어나지 않습니다 ... 또한 오디오 플레이어가 재생되는지 확인하기위한 체크를 추가하고 그것이 아니라고 말합니다 ... 새 코드를 보여주기 위해 질문을 업데이트했습니다 ... – Blue
Okay check 내 새 편집. 당신의 경로가 엉망이 된 것처럼 들립니다 ... –
코드를 업데이트했습니다 ... 여전히 작동하지 않지만 많은 오류가 있습니다 ... 질문의 코드를 확인하십시오 ... – Blue