0

I'm working on hobby project. I'm using createjs. But, of course, I have a problem. Since I update the code to use Preloadjs, the browser can no longer find the audio files. Here is my loading code:

function load (canvasToShowProgress) {
    canvas = canvasToShowProgress;
    loadingStage = new createjs.Stage();
    loadQueue = new createjs.LoadQueue(true);
    progessText = new createjs.Text("Loading... 0%");
    loadingStage.addChild(loadingStage);
    loadingStage.update();

    //start loading
    loadQueue.installPlugin(createjs.Sound);
    loadQueue.setMaxConnections(4); // Allow 4 concurrent loads
    loadQueue.loadManifest("configuration/GameAssets.json");
    loadQueue.on("progress", handleProgress);
    loadQueue.on("complete",handleComplete);
}

My manifest GameAssets.json looks like this:

{"manifest":
[   {"src":"images/game/street.png", "id":"street"},
    {"id":"Default", "src":"sounds/game/background.ogg"},
    {"id":"Psychic", "src":"sounds/game/ps.ogg"},
    {"id":"Nitro", "src":"sounds/game/ntr.ogg"}
]
}

By the way, the image is loaded perfectly. In the music player class, I call the audio by simply doing soundInstance = createjs.Sound.play(soundIds[currentPlayIndex]);. (The soundIds is temporary a hardcoded array with the ids. Where is my mistake?

user2810895
  • 1,284
  • 3
  • 19
  • 33

2 Answers2

0

Your soundIds array declare like this

var soundIds=["Default","Psychic","Nitro"]

then call it like that

createjs.Sound.play(soundIds[0]);
ThariUCSC
  • 9
  • 2
0

First, I just want to confirm you are using the latest 0.6.0 releases of both SoundJS and PreloadJS (they need to be used together).

Currently only Firefox and Chrome support Ogg, so if you are using another browser you would need to provide and alternate format (mp3 is currently the most broadly supported) and set it up using SoundJS.alternateExtensions.

If you are still having loading errors, you'd likely need to dig into the errors a little more to determine the cause.

Hope that helps.

OJay
  • 1,249
  • 7
  • 14
  • I'm using both SoundJS and PreloadJS v0.6.0 (min version). The error I get on the console is `GET http://localhost/game/Oggs HTTP/1.1 404 Not Found`. I'm using Firefox on Ubuntu 14.04LTS. To support mp3, do I need to add e.g. a line like this in the manifest: `{"id":"Psychic", "src":"sounds/game/ps.mp3"}`? – user2810895 Jan 18 '15 at 17:16
  • The strange thing is, if I use a manifest inside the js code, it all works perfectly. So perhaps an error in my manifest? – user2810895 Jan 18 '15 at 17:33
  • Yup sounds like the error is in the manifest as the requested file does not make sense. You can set fallback filetypes using [alternateExtensions](http://www.createjs.com/Docs/SoundJS/classes/Sound.html#property_alternateExtensions). – OJay Jan 20 '15 at 05:07