views:

25

answers:

1

Hello there,

Does anybody know if it is possible to handle interruption by AVPLayer delegate when I have more then one AVPlayer? I have tried few things to start again two AVPlayer after phone call, but still only one respond and started, the second one was paused and did nothing.

thank you in advance for any idea

Vanya

A: 

My guess is that you need to keep an array of your players so that you can poll through them and pause/start each one. You can add each to an array when you create the player which you can access in audioPlayerBeginInterruption: and audioPlayerEndInterruption:

Apple's docs imply that the interruptions only handle one player ...if the class had stated a method input of players instead of player then I would have said you could have just done a for loop to poll through them like the code below:

AVAudioPlayer *player; 
for (player in players) {

    [player pause];
    //or [player play];
}

http://developer.apple.com/iphone/library/documentation/AVFoundation/Reference/AVAudioPlayerDelegateProtocolReference/Reference/Reference.html#//apple_ref/occ/intfm/AVAudioPlayerDelegate/audioPlayerBeginInterruption:

iWasRobbed