Jump to content

Understanding Audio Sprite JSON format and loader


Recommended Posts



I am developing an Asset Manager editor for Eclipse and I need a better understanding of how the audio sprites work.


My doubt is about the JSON format of the audio sprite. In the Phaser doc it says:


"Audio Sprites are a combination of audio files and a JSON configuration. The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite"


This is the example (of the audio sprite JSON) there is in that github repo overview:


{  "resources": [    "mygameaudio.caf",    "mygameaudio.ac3",    "mygameaudio.mp3",    "mygameaudio.m4a",    "mygameaudio.ogg"  ],  "spritemap": {    "bg_loop": {      "start": 0,      "end": 3.75,      "loop": true    },    "click": {      "start": 5,      "end": 5.3,      "loop": false    }  },  "autoplay": "bg_loop"}

Note there is a "resource" section where are listed the audio files of the same "sound", but with different format.


Now, if you see the "audiosprite" method of Phaser, it requires to pass the "urls" of the sounds files. So for me this is redundant. I see in the Loader code that it always load the audio files given in the "urls" parameter.


I think what happen is that Phaser ignores the "resources" section of the JSON. Is it true?


Maybe it is better to read the "urls" from the JSON too, but well, for now I just need to someone to confirm the "resources" section of the JSON is ignored.


Thanks in advance







Link to comment
Share on other sites

Well, I think I understand why the "resources" section is ignored.


I think it is because if the JSON is get from a file it is loaded (via loader.json(...) method) asynchronously, so at that moment the "resources" are not available yet. For that reason it is requesting them as parameter.

In the tool then I can help with this, if the JSON file has the "resources", I put set them automatically as "urls" parameter.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...