2つのAVAudioPlayerオブジェクトで2つのサウンドを同時に正確に再生する必要があります...そのため、この例はApple AVAudioPlayerクラスリファレンス(https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/)で見つかりました。 AVAudioPlayerClassReference / Reference / Reference.html):
- (void) startSynchronizedPlayback {
NSTimeInterval shortStartDelay = 0.01; // seconds
NSTimeInterval now = player.deviceCurrentTime;
[player playAtTime: now + shortStartDelay];
[secondPlayer playAtTime: now + shortStartDelay];
// Here, update state and user interface for each player, as appropriate
}
私が理解していないのは、なぜsecondPlayerにもshorStartDelayがあるのかということです。なくてはいけませんか?最初のプレーヤーは2番目のプレーヤーの前に呼び出されるので0.1秒の遅延が必要だと思いました...しかし、このコードでは2人のプレーヤーに遅延があります...それが正しいかどうか、そしてその理由は誰でも説明できますか?どうもありがとうマッシー