audio-and-sound

Implements audio playback, spatial sound, and volume control in Phaser 4 games.

465|41|Updated Aug 4, 2026
One-click install
npx skills add https://github.com/autonomous-ai/openharness --skill audio-and-sound-autonomous-ai
Or copy as Structured Prompt for Agentā–¼
Please help me install this Agent Skill.
Skill: audio-and-sound
Source: https://github.com/autonomous-ai/openharness/tree/main/store/agents/phaser/skills/audio-and-sound
Command: npx skills add https://github.com/autonomous-ai/openharness --skill audio-and-sound-autonomous-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding sound to a Phaser game involves navigating WebAudio versus HTML5 Audio backends, browser autoplay policies, audio sprites, and spatial positioning, which is easy to get wrong without a reference. ## Core Features & Use Cases - Sound Playback Control: Play, pause, loop, seek, and adjust volume, rate, detune, and pan per sound or globally via the SoundManager. - Audio Sprites and Markers: Combine multiple effects into one file with JSON spritemaps, or define manual markers for segmented playback. - Spatial Audio: Position sounds in 2D space with PannerNode configs and listener tracking on WebAudio backends. - Use Case: Build a game scene that loads background music and sound effects in preload, plays looping BGM at reduced volume, fires positional enemy roars that follow sprites, and handles browser autoplay unlocking automatically. ## Quick Start Add background music and a coin sound effect to my Phaser scene, with the music looping at half volume and the coin sound playing on click.

Frequently Asked Questions about audio-and-sound

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

FAQPage Schema
How do I play sound effects and music in a Phaser game?ā–¼

Load audio files with this.load.audio() in preload, then call this.sound.play(key) for fire-and-forget effects or this.sound.add(key) for a retained reference you can pause, stop, and adjust. Provide an array of formats like OGG and MP3 for cross-browser support.

How do I loop background music in Phaser?ā–¼

Create the sound with a loop config: this.sound.add('music', { loop: true, volume: 0.5 }) then call play(). The LOOPED event fires each time it restarts, and you must stop it manually on scene shutdown since the SoundManager is shared globally.

Does Phaser support spatial or positional audio?ā–¼

Phaser supports spatial audio only on the WebAudio backend using PannerNode. Pass a source config with x, y, refDistance, and rolloffFactor when adding a sound, set the listener with this.sound.setListenerPosition(), and optionally use follow to track a Game Object.

Why is my Phaser game audio not playing on mobile browsers?ā–¼

Browsers block audio until user interaction, so the AudioContext starts suspended. Phaser unlocks it automatically on the first touch or key event; check this.sound.locked and listen for the unlocked event before starting playback.

What is the difference between WebAudio and HTML5 Audio in Phaser?ā–¼

WebAudio offers precise timing, gapless looping, stereo panning, and spatial audio, while HTML5 Audio is a fallback with no spatial support and limited simultaneous playback requiring an instances count. Phaser auto-selects WebAudio unless disabled via game config.