spatial-audio-sound

Add RealityKit spatial audio and non-spatial UI sound effects to visionOS apps.

Updated Jun 8, 2026
One-click install
npx skills add https://github.com/likw99/agent-plugins --skill spatial-audio-sound-likw99
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: spatial-audio-sound
Source: https://github.com/likw99/agent-plugins/tree/main/plugins/build-visionos-apps/skills/spatial-audio-sound
Command: npx skills add https://github.com/likw99/agent-plugins --skill spatial-audio-sound-likw99

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Adding sound to a visionOS app involves choosing between RealityKit spatial audio on entities and simpler non-spatial playback, and mistakes like loading audio on the playback path or letting an AVAudioPlayer deinit cause silent or glitchy results. This Skill provides the decision logic and correct code patterns for both approaches. ## Core Features & Use Cases - Spatial audio on entities: Play positional 3D sound from RealityKit entities using AudioFileResource, SpatialAudioComponent, and AudioPlaybackController, with reverb and ambient/channel components. - Non-spatial UI sound effects: Play one-shot chimes and tap sounds with AVAudioPlayer or AudioServicesPlaySystemSound in 2D window flows. - Use Case: When a long async job finishes in your visionOS app, play a completion chime exactly once on the status transition — spatially from the model entity if one exists, or via a retained AVAudioPlayer in a plain SwiftUI flow. ## Quick Start Use the spatial-audio-sound skill to play a completion chime when my model generation task finishes in my visionOS app.

Frequently Asked Questions about spatial-audio-sound

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I play spatial audio on a RealityKit entity in visionOS?▼

Preload an AudioFileResource, attach a SpatialAudioComponent to the entity to shape gain and directivity, then call entity.playAudio(resource). Audio is spatial by default in RealityKit, positioned in 3D at the entity's location.

How to play a simple sound effect in a SwiftUI visionOS app?▼

Use AVAudioPlayer loaded from a bundled wav file, stored as a property so it is not deallocated mid-playback. For very short effects, AudioServicesPlaySystemSound from AudioToolbox works as a fire-and-forget option without volume control.

Why does my AVAudioPlayer sound not play in Swift?▼

The most common cause is declaring AVAudioPlayer as a local variable, which deinitializes when the function returns and stops playback. Store the player as a property on a long-lived object and call prepareToPlay before play.

What is the difference between SpatialAudioComponent and ChannelAudioComponent?▼

SpatialAudioComponent positions sound in 3D from an entity with distance attenuation and directivity. ChannelAudioComponent sends audio straight to output with no spatialization, making it the right choice for non-diegetic background music.

Can I loop background audio in RealityKit visionOS apps?▼

Yes, load the AudioFileResource with a configuration where shouldLoop is true, then play it on an entity. Retain the AudioPlaybackController from prepareAudio so you can stop the loop when the scene disappears or the task completes.