{"record":{"id":"f22cb6ea9328ed3b","repo":"phaserjs/phaser","slug":"audio-key","errorCode":null,"errorMessage":"Audio key \"","messagePattern":"Audio key \"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/sound/webaudio/WebAudioSound.js","lineNumber":58,"sourceCode":"\n    initialize:\n\n    function WebAudioSound (manager, key, config)\n    {\n        if (config === undefined) { config = {}; }\n\n        /**\n         * Audio buffer containing decoded data of the audio asset to be played.\n         *\n         * @name Phaser.Sound.WebAudioSound#audioBuffer\n         * @type {AudioBuffer}\n         * @since 3.0.0\n         */\n        this.audioBuffer = manager.game.cache.audio.get(key);\n\n        if (!this.audioBuffer)\n        {\n            throw new Error('Audio key \"' + key + '\" not found in cache');\n        }\n\n        /**\n         * A reference to an audio source node used for playing back audio from\n         * audio data stored in Phaser.Sound.WebAudioSound#audioBuffer.\n         *\n         * @name Phaser.Sound.WebAudioSound#source\n         * @type {?AudioBufferSourceNode}\n         * @default null\n         * @since 3.0.0\n         */\n        this.source = null;\n\n        /**\n         * A reference to a second audio source used for gapless looped playback.\n         *\n         * @name Phaser.Sound.WebAudioSound#loopSource\n         * @type {?AudioBufferSourceNode}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/sound/webaudio/WebAudioSound.js#L40-L76","documentation":"Thrown by WebAudioSound constructor when manager.game.cache.audio.get(key) returns a falsy value. Identical cause to the HTML5 path but for the WebAudio backend: the decoded AudioBuffer must be present in the audio cache before a WebAudioSound can wrap it.","triggerScenarios":"Constructing new Phaser.Sound.WebAudioSound(manager, key) for an unloaded key; misspelled key; loader not yet complete; audio decode failed so the buffer is missing from cache.","commonSituations":"Forgetting the load.audio call; calling from preload instead of create; failed/aborted decode (corrupt file, unsupported codec); key mismatch between load and add; audio type mismatch (e.g. loading as text).","solutions":["Preload with this.load.audio(key, url) using the exact key.","Defer sound.add to create() or a loader.on('complete') callback.","Guard with this.game.cache.audio.has(key).","Confirm the file is a browser-supported codec and loads without 404."],"exampleFix":"// before\nthis.sound.add('music'); // not loaded\n\n// after\npreload() { this.load.audio('music', 'audio/music.ogg'); }\ncreate() { this.sound.add('music'); }","handlingStrategy":"validation","validationCode":"function addWebAudioSound(manager, key) {\n  if (!manager.game.cache.audio.has(key)) {\n    throw new Error(`Audio '${key}' not in cache; call this.load.audio first`);\n  }\n  return new Phaser.Sound.WebAudioSound(manager, key);\n}","typeGuard":"function audioCached(game, key) { return game.cache.audio.has(key); }","tryCatchPattern":null,"preventionTips":["Preload with this.load.audio.","Wait for loader completion before sound.add.","Verify file format and HTTP status."],"tags":["audio","sound","cache","webaudio","loader"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}