viewDidLoad
방법으로 사운드 파일을 재생 중입니다. 사운드 파일은 문서 디렉토리에 저장됩니다. 뷰가 처음로드 될 때 성공적으로 재생됩니다. 그러나 내가이 관점을 터뜨렸을 때 돌아 오면 연주되지 않습니다. 당신이보기에서 돌아 오는 후이 방법을 재생하려면재생중인 사운드 파일 iOS
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *localFilePathSound =[[NSString alloc] initWithString:[documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"sound.caf"]]];
if ([[NSFileManager defaultManager] fileExistsAtPath:localFilePathSound]) {
//NSString *clapPath = [[NSBundle mainBundle] pathForResource:@"scaryVoice" ofType:@"wav"];
CFURLRef clapURL = (CFURLRef) [NSURL fileURLWithPath:localFilePathSound];
AudioServicesCreateSystemSoundID (clapURL, &clappingFileId);
AudioServicesPlaySystemSound(clappingFileId);
}
// Do any additional setup after loading the view from its nib.
else{
NSString *clapPath = [[NSBundle mainBundle] pathForResource:@"scaryVoice" ofType:@"wav"];
CFURLRef clapURL = (CFURLRef) [NSURL fileURLWithPath:clapPath];
AudioServicesCreateSystemSoundID (clapURL, &clappingFileId);
AudioServicesPlaySystemSound(clappingFileId);
}
}
여전히 문제가 있습니까? –
예 그래도 해보았지만 여전히 같은 문제에 직면 해 있습니다. –