reality-composer-pro

Make a SpatialAudio source autoplay in Reality Composer Pro?


Is there a way to make a SpatialAudio object autoplay its assigned track strictly via settings in Reality Composer Pro, no Swift code involved?


Solution

  • Playing spatial audio with zero-code in RCP 2.0 scene

    Yep, this is possible thanks to the new version of RCP. I chose AtmospheresOcean .caf audio from Reality Composer Pro's free library. Then I put a track in Timelines editor. After that I added the OnAddedToScene behavior with Timeline action on Entity. And do not forget to supply AudioLibrary resources with AtmospheresOcean sound.

    enter image description here

    This code is enough to auto-play your spatial sound as soon as the scene starts.

    RealityView { rvc in
        let scene = try! await Entity(named: "Immersive", in: rkcb)
        rvc.add(scene)
    }