9.2. Obsługa zakłóceń podczas odtwarzania treści audio

Problem

Chcesz, aby egzemplarz AVAudioPlayer wznowił odtwarzanie treści audio po wystąpieniu zakłócenia w urządzeniu iOS, np. po otrzymaniu połączenia przychodzącego.

Rozwiązanie

Zaimplementuj metody audioPlayerBeginInterruption: i audioPlayerEndInterruption:withFlags: protokołu AVAudioPlayerDelegate w obiekcie delegata zdefiniowanego dla egzemplarza AVAudioPlayer.

- (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player
{
   /* Sesja audio została przerwana. W tym miejscu odtwarzacz wstrzyma odtwarzanie treści audio. */ } - (void)audioPlayerEndInterruption:(AVAudioPlayer *)player withFlags:(NSUInteger)flags { if (flags == AVAudioSessionInterruptionFlags_ShouldResume && player != nil) { [player ...

Get iOS 5. Programowanie. Receptury now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.