Skip to content
phaserjs avatar

Audio And Sound

Phaser 4 audio guide covering WebAudio and HTML5 backends, SoundManager, volume, looping, markers, and spatial audio.

CCM score
81 of 100
skills.sh installs
1.3K
GitHub stars
40.8K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers loading, fire-and-forget and retained playback, volume, rate, detune, looping, seeking, and stereo panning
  • Includes audio sprites and markers, with the audiosprite JSON format and manual marker APIs for segmenting tracks
  • Explains automatic backend selection (WebAudio, HTML5, or no-op) and config flags such as disableWebAudio and noAudio
  • Designed for Phaser 4 projects that need background music, sound effects, or positional sound effects in 2D scenes

Install

$ npx -y skills add phaserjs/phaser --skill audio-and-sound -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Audio and Sound

Phaser provides a unified Sound system via this.sound (a SoundManager) that abstracts over Web Audio API and HTML5 Audio. It handles loading, playback, volume, panning, looping, markers, audio sprites, spatial audio, and browser autoplay-policy unlocking.

Key source paths: src/sound/BaseSoundManager.js, src/sound/BaseSound.js, src/sound/webaudio/, src/sound/html5/, src/sound/SoundManagerCreator.js, src/sound/events/, src/sound/typedefs/ Related skills: ../loading-assets/SKILL.md, ../game-setup-and-config/SKILL.md

Quick Start

class GameScene extends Phaser.Scene {
    preload() {
        this.load.audio('bgm', 'assets/music.mp3');
        this.load.audio('coin', ['assets/coin.ogg', 'assets/coin.mp3']);
    }

    create() {
        // Fire-and-forget (auto-destroys when complete)
        this.sound.play('coin');

        // Retained reference for ongoing control
        this.music = this.sound.add('bgm', { loop: true, volume: 0.5 });
        this.music.play();
    }
}

Assets loaded via this.load.audio() in preload() are ready by the time create() runs. Provide an array of URLs for cross-browser format fallback.

Details

Repository
github.com/phaserjs/phaser
Categories
Game Development, Frontend & UI Code
First seen
Jun 3, 2026

Questions

What does the audio-and-sound skill help an agent do?

It guides an agent through adding audio or sound to a Phaser 4 game, covering loading audio, playing sounds, music, volume, spatial audio, the Web Audio API and the SoundManager. It is triggered by requests mentioning sound, audio, music, volume or mute.

How do I install the audio-and-sound skill?

Run npx -y skills add phaserjs/phaser --skill audio-and-sound -y inside your project. Once installed, the agent can use the skill's guidance on Phaser's unified Sound system via this.sound.

Which skills lead audio-and-sound in the Game Development category?

Within the Game Development category, the skills listed alongside it are higgsfield-game-generation, game-feel, game-ui-ux, godot-gdscript-patterns and level-design. This skill focuses specifically on sound and audio inside Phaser 4 games.

Does the audio-and-sound skill support spatial audio and browser autoplay unlocking?

Yes, the SKILL.md covers spatial audio positioning with a listener and sources, along with browser autoplay-policy unlocking handled by the SoundManager. Spatial audio applies to the WebAudio backend, which Phaser selects automatically when the device supports it.

More from phaserjs/phaser

All 8

Similar to Audio And Sound

More Game Development