play(atTime:)
Plays audio asynchronously, starting at a specified point in the audio output device’s timeline.
Declaration
func play(atTime time: TimeInterval) -> BoolParameters
- time:
The audio device time to begin playback. This time must be later than the device’s current time.
Return Value
Discussion
Use this method to precisely synchronize the playback of two or more audio player objects as the following example shows:
func startSynchronizedPlayback() {
// Create a time offset relative to the current device time.
let timeOffset = playerOne.deviceCurrentTime + 0.01
// Start playback of both players at the same time.
playerOne.play(atTime: timeOffset)
playerTwo.play(atTime: timeOffset)
}Calling this method implicitly calls prepareToPlay() if the audio player is unprepared for playback.