开发者

Handle iPhone interruption in a music application

开发者 https://www.devze.com 2023-01-11 16:45 出处:网络
I\'ve tried the code to avoid the sleep mode interruption. It\'s working, but now I have a problem with interruptions when a call or sms is coming in to the iPhone. The song in my music application is

I've tried the code to avoid the sleep mode interruption. It's working, but now I have a problem with interruptions when a call or sms is coming in to the iPhone. The song in my music application is stopped at that time. I want to automatically resume the song where it was stopped once the call is over.

- (void) audioPlayerBeginInterruption: (AVAudioPlayer *) player {

if (playing) {

    playing = NO;

    interruptedOnPlayback = YES;

    [self updateViewForPlayerState];

}

}


- (void) audioPla开发者_如何转开发yerEndInterruption: (AVAudioPlayer *) player {

if (interruptedOnPlayback) {

    [player prepareToPlay];

    [player play];

    playing = YES;

    interruptedOnPlayback = NO;

}

}

But it doesn't work. Please help me here, thanks in advance.


Try Apple's guide to Audio Interruptions.

0

精彩评论

暂无评论...
验证码 换一张
取 消