2012-05-24 5 views
0

그래서 내가 찾은 관련 질문을 대부분 읽었지만 침묵하는 동안 내 오디오를 재생할 수 없습니다. 나는 아마도 내가 만든 작은 실수라고 생각한다.iOS : 자동 모드를 사용할 때 사운드를 재생할 수 없습니다.

작은 경고음을 재생하려고합니다. 이것은 내 viewDidLoad 방법에 코드입니다 :

AudioSessionInitialize (NULL, NULL, NULL, NULL); 
AudioSessionSetActive(true); 

을 그리고 여기 내가 SO 오프이 대부분을 얻었고, 그것을 확인

-(void)playAudioClip:(CFStringRef)clip{ 

CFBundleRef mainBundle = CFBundleGetMainBundle(); 
CFURLRef soundFile = CFBundleCopyResourceURL(mainBundle, clip, CFSTR("wav"), NULL); 

//Supposed to make sound playable even when silent right? 
UInt32 soundType = kAudioSessionCategory_MediaPlayback; 
UInt32 soundID; 

AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(soundType), &soundType); 
AudioServicesCreateSystemSoundID(soundFile, &soundID); 
AudioServicesPlaySystmSound(soundID); 
} 

오디오 클립을 재생해야 할 때 내가 전화하는 방법입니다 Apple 프로그래밍 가이드 나는 이미 두 가지 용도로 Uint32을 결합하려고 시도했으나 아무 것도하지 않았으며 잠긴/자동 모드에서는 여전히 재생되지 않았습니다. 어떤 아이디어?

+1

자동 모드는 무음 상태로 설정됩니다. – DanSkeel

+0

[AudioServicesPlaySystemSound] (http://developer.apple.com/library/ios/documentation/AudioToolbox/Reference/SystemSoundServicesReference/Reference/reference.html#/)에 대한 설명서를 읽어보십시오./apple_ref/c/func/AudioServicesPlaySystemSound) – Joe

+0

@Joe 나는 이것을 읽었으며, 나는 그것을 벗어나기 위해 무엇을해야하는지 완전히 확신하지 못했다. –

답변

1

시스템 소리는 자동 모드 일 때 재생되지 않습니다. (이름에서 알 수 있듯이) 무성 중일 때 오디오를 재생해야하는 경우 미디어 플레이어 나 다른 오디오 방법과 같은 다른 방법을 사용해야합니다. 음악 재생에 대한 Apple의 사례를 살펴보십시오.

관련 문제