AVPlayer를 사용하여 다른 음원 (iPod 뮤직 라이브러리 포함)에서 사운드를 재생하고 있습니다. 사실 AVPlayer가 더 낮은 수준의 AVAudioPlayer이기 때문에 나는 스스로 중단을 처리해야합니다. AVAudioPlayer를 사용하는 것은 옵션이 아닙니다!iOS가 오디오 세션 중단에 대해 내 애플리케이션에 알리지 않는 이유는 무엇입니까?
애플 개발자 문서에서는 AVAudioSessionInterruptionNotification
을 듣거나 AudioSessionInitialize
으로 수신기를 설정합니다. 하지만 그렇게 할 때 은 인터럽트가으로 끝났을 때만 알림을 받지만, their documents으로 인해 은을 모두 처리 할 수 있어야합니다. (간체 버전 제거 중요하지 않은 선) 리스너처럼 보이는 방법
AudioSessionInitialize(NULL, NULL, ARInterruptionListenerCallback, nil);
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
AudioSessionSetActive(true);
그리고 여기입니다 : Btw는
void ARInterruptionListenerCallback(void *inUserData, UInt32 interruptionState) {
if (interruptionState == kAudioSessionBeginInterruption) {
// Here is the code which is never called...
}
else if (interruptionState == kAudioSessionEndInterruption) {
// But this case will be executed!
}
}
내 오디오 세션을 초기화하려면 다음 코드를 사용하고 있습니다. 이 코드는 전화 통화 나 이와 유사한 중단이있을 때 실행될 것으로 예상됩니다. Apple이 중단으로 선언 한 내용을 오해하고 있습니까?
감사를 참조하십시오. 나는 이와 비슷한 일을 또한 만들었다. 저는 지금이 문제를보고 할 것입니다. – miho