audio-and-sound

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

Updated Jul 13, 2026
One-click install
npx skills add https://github.com/russellmorgan/UnderConstruction --skill audio-and-sound-russellmorgan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: audio-and-sound
Source: https://github.com/russellmorgan/UnderConstruction/tree/main/.claude/skills/audio-and-sound
Command: npx skills add https://github.com/russellmorgan/UnderConstruction --skill audio-and-sound-russellmorgan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding sound to a Phaser 4 game involves navigating WebAudio versus HTML5 Audio backends, browser autoplay policies, looping music, audio sprites, and spatial positioning. This Skill provides the patterns, API references, and gotchas needed to implement game audio correctly the first time. ## Core Features & Use Cases - Sound Playback Patterns: Covers fire-and-forget playback via this.sound.play(), retained sound instances via this.sound.add(), looping background music, volume/rate/detune control, and stereo panning. - Audio Sprites and Markers: Explains loading audio sprites with JSON spritemaps and adding manual markers to split long tracks into named segments. - Spatial Audio and Events: Documents WebAudio-only spatial audio with listener positioning and follow tracking, plus the full sound event model (PLAY, COMPLETE, LOOPED, UNLOCKED, and more). - Use Case: You are building a Phaser game and need background music that loops, coin-pickup sound effects with format fallbacks for Safari, and positional enemy roars that pan based on screen location. ## Quick Start Add background music and a coin sound effect to my Phaser scene, with MP3 and OGG fallbacks and handling for the browser autoplay lock.

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 Phaser?▼

Load audio in preload() with this.load.audio(), then use this.sound.play('key') for fire-and-forget effects or this.sound.add('key', { loop: true }) followed by play() for music you need to control later. Provide an array of URLs for format fallback.

WebAudio vs HTML5 Audio in Phaser, which should I use?▼

Phaser auto-selects WebAudio when available, which offers precise timing, gapless looping, stereo panning, and spatial audio. HTML5 Audio is the fallback but lacks spatial audio and real panning. Force HTML5 with audio: { disableWebAudio: true } in the game config.

Why is my Phaser game audio not playing on mobile browsers?▼

Browsers block audio until user interaction, so the AudioContext starts suspended. Phaser handles unlocking automatically on touch or key input. Check this.sound.locked and wait for the 'unlocked' event before playing sounds at startup.

Does Phaser support spatial or positional audio?▼

Yes, but only with the WebAudio backend. Pass a source config with x, y, refDistance, and rolloffFactor when adding a sound, and set the listener with this.sound.setListenerPosition(). The source config is silently ignored under HTML5 Audio.

How do I play multiple instances of the same sound in Phaser?▼

With WebAudio, simultaneous playback works without configuration. With HTML5 Audio, specify an instances count when loading, such as this.load.audio('shot', 'shot.mp3', { instances: 4 }), since the default pool size is one audio tag.