audio-and-sound

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding sound to a Phaser game involves navigating Web Audio versus HTML5 Audio backends, browser autoplay restrictions, looping music, audio sprites, and spatial positioning, all of which have subtle platform-specific pitfalls. ## Core Features & Use Cases - Sound Playback Control: Play fire-and-forget effects or manage persistent sound instances with volume, rate, detune, pan, seek, and loop settings via the SoundManager. - Audio Sprites and Markers: Combine multiple effects into single files with JSON spritemaps, or define named markers within long tracks for segmented playback. - Spatial Audio: Position sounds in 2D space with PannerNode configs, distance models, and automatic tracking of game objects relative to a listener. - Use Case: When building a game scene, load background music and sound effects in preload, play looping BGM with volume control, trigger positional enemy sounds that follow sprites, and handle 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 when the player collects an item.

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 files in preload with this.load.audio, then call this.sound.play(key) for fire-and-forget effects or this.sound.add(key) for a persistent instance you can pause, stop, and adjust. Provide an array of formats like OGG and MP3 for cross-browser support.

How to loop background music in a Phaser game?

Create the sound with a loop config: this.sound.add('bgm', { 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 audio and stereo panning?

Spatial audio works only with the WebAudio backend using PannerNode, configured via the source property with position, distance model, and an optional follow target. On HTML5 Audio or iOS Safari, pan and spatial settings fire events but produce no audible effect.

Why is my Phaser 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 click; check this.sound.locked and listen for the unlocked event before playing sounds at startup.

What are the limitations of HTML5 Audio in Phaser?

HTML5 Audio lacks spatial audio and real stereo panning, has less precise looping, and requires an instances count at load time for simultaneous playback of the same sound. WebAudio is the default backend and avoids these limitations.