AVAudioSession endInterruption() returns an NSOSStatusErrorDomain

后端 未结 4 1378
眼角桃花
眼角桃花 2021-01-21 10:16

I\'m trying to solve an AVAudioSession problem since many hours ago and didn\'t get success!!

I found lots of guys talking about problems with endInterruption but none o

4条回答
  •  盖世英雄少女心
    2021-01-21 11:10

    Using @Trinca answer that what I did on "ARC'ed" project:

    AudioSessionInitialize (NULL, NULL, interruptionListenerCallback, (__bridge void *)(self.player));
    

    Were self.player is your player instance that you pass to the callback function.

    Then implement the callback:

    void interruptionListenerCallback (void *inUserData, UInt32 interruptionState) {
       NSLog(@"itnerp state %li",interruptionState);
       NSLog(@"inUserData %@",inUserData);
       AVAudioPlayer *pl = (__bridge AVAudioPlayer*)inUserData;
       switch (interruptionState) {
        case 0:
            [pl play];
        break;
    
        case 1:
            [pl pause];
        break;
       }
    
    }
    

    GOOD LUCK

    Shani

提交回复
热议问题