开发者

Handle iPhone interruption in a music application

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜