Load Audio Sprite

This example demonstrates how to load an audio sprite using a JSON configuration file and multiple audio formats, then play specific sound markers defined within the sprite.

Load Audio Sprite, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.setPath('assets/audio/kyobi/');

        this.load.audioSprite('kyobi', 'kyobi.json', [
            'kyobi.ogg',
            'kyobi.mp3',
            'kyobi.m4a'
        ]);
    }

    create ()
    {
        const music = this.sound.addAudioSprite('kyobi');

        music.play('title');

        // music.play('gameOver');
        // music.play('nextLevel');

        // text.setText('Playing Dafunk - Hardcore Power (We Believe In Goa - Remix)');
    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    parent: 'game-container',
    scene: Example
};

const game = new Phaser.Game(config);

More in Audio5 examples