问题
I am using multiple instances of AVAudioPlayer to play multiple sound files in a succession.
I am noticing that there is a roughly one second pause when two different sound files are played. Is it possible to eliminate this one second pause? I call [myPlayer prepareToPlay] for each player ahead of time already.
回答1:
According to AVAudioPlayer documentation you could use playAtTime: for synchronized playing.
Modified example would look like this:
- (void) startSynchronizedPlayback {
NSTimeInterval shortStartDelay = 0.01; // seconds
NSTimeInterval now = player.deviceCurrentTime;
[player playAtTime: now + shortStartDelay];
[secondPlayer playAtTime: now + shortStartDelay + player.duration];
}
I didn't test this but guess it should work. You should of course rename player and secondPlayer according to you names.
来源:https://stackoverflow.com/questions/11196345/avaudioplayer-eliminating-one-second-pause-between-sound-files