中断结束后恢复两个AVAudioPlayer

时间:2012-03-01 08:29:29

标签: iphone ios avaudioplayer

我正在使用两个我一起玩的AVAudioPlayer对象。当中断发生时,我暂停两个对象,当中断结束时,我同时播放AVAudioPlayer对象,但奇怪的是,第一个播放但另一个播放不播放。如果我先玩第二个玩家,那么第二个玩家会被玩,但第一个玩家不玩。请有人帮帮我吗?

1 个答案:

答案 0 :(得分:0)

//This isn't a solution, but should work fine in case you need to want like this !!

//While resuming your first AVAudioPlayer object
NSTimer *timer=[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(playSecondObject) userInfo:nil repeats:NO];

[AVAudioPlayerObject1 play] //from pause

}

- (void) playSecondObject
{
[AVAudioPlayerObject2 play]; 
//The timer will fire and call this method and can play second object, 
the time difference can be checked by you to set the exact that what you want?
}

//Hope this helps