RealityKit: How to read the current audio playback position, and sync audio across multiple entities?

Hi,

in RealityKit, AudioPlaybackController exposes duration, gain, speed, play/pause/stop, and a completion handler, but I can't find a way to read the current playhead position while a resource is playing. I need this to trigger animations and other timed events in sync with the audio.

Is there a supported way to read the current playback position on AudioPlaybackController? If not, is this planned any time soon?

Also, is there a sample-accurate way to start/keep audio playback in sync across multiple entities in RealityKit?

Appreciate any guidance, thanks.

Hi @Maederd,

To answer your second question, yes, you can synchronize audio playback across multiple entities by calling Entity.playAudio(_:at:) with the same AVAudioTime for each:

This method enables sample-accurate timing for individual sounds and synchronization of multiple audio sources.

As for AudioPlaybackController, while it doesn't expose the current playback position directly with an API you can always leverage the AVAudioTime instance from the aforementioned playAudio(_:at:) method to track the elapsed playback time and trigger actions/animations at specific times during playback.

If using AVAudioTime isn't sufficient, I'd love to hear more about your specific use case and also encourage you to file an enhancement request using Feedback Assistant so we can consider adding the necessary functionality.

Let me know if you have any questions, thanks!

RealityKit: How to read the current audio playback position, and sync audio across multiple entities?
 
 
Q