Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIXI's Loader is not loading sounds as ArrayBuffer, unable to decode #18

Closed
bigtimebuddy opened this issue May 11, 2017 · 4 comments
Closed

Comments

@bigtimebuddy
Copy link
Member

As reported by @FunkyPaul on pixi.js Slack...

This works fine.

let soundsMap = {
    "game_start": "assets/sounds/game_start.ogg",
    "spin_ready": "assets/sounds/spin_ready.ogg",
    "spin_loop": "assets/sounds/spin_loop.ogg",
    "spin_stop": "assets/sounds/spin_stop.ogg",
    "win_loop": "assets/sounds/win_loop.ogg",
    "game_end": "assets/sounds/game_end.ogg",
    "spin_start": "assets/sounds/spin_start.ogg",
    "spin_tick": "assets/sounds/spin_tick.ogg"
};
sound.add(soundsMap, {
    preload: true
});

This throws the error below:

let loader = new PIXI.loaders.Loader();
loader
    .add("game_start", "assets/sounds/game_start.ogg")
    .add("spin_ready", "assets/sounds/spin_ready.ogg")
    .add("spin_loop", "assets/sounds/spin_loop.ogg")
    .add("spin_stop", "assets/sounds/spin_stop.ogg")
    .add("win_loop", "assets/sounds/win_loop.ogg")
    .add("game_end", "assets/sounds/game_end.ogg")
    .add("spin_start", "assets/sounds/spin_start.ogg")
    .add("spin_tick", "assets/sounds/spin_tick.ogg")
    .add("font_dark", "assets/fonts/font_dark.fnt")
    .add("font_light", "assets/fonts/font_light.fnt")
    .load(function (loader, resources) {
        this.loadAnimateScene();
    }.bind(this));
Uncaught (in promise) TypeError: Failed to execute 'decodeAudioData' on 'BaseAudioContext': parameter 1 is not of type 'ArrayBuffer'.
    at SoundContext.decode (SoundContext.js:156)
    at Sound._decode (Sound.js:355)
    at Sound._beginPreload (Sound.js:295)
    at new Sound (Sound.js:54)
    at SoundLibrary.add (SoundLibrary.js:65)
    at Loader.middleware (LoaderMiddleware.js:7)
    at Loader.js:590
    at next (async.js:32)
    at Loader.bitmapFontParser (bitmapFontParser.js:10)
    at Loader.js:590

Environment

  • Windows 8
  • Chrome 57 (64-bit)
  • pixi-sound@1.4.1
  • pixi.js@4.4.3, pixi.sj@4.5.1
  • problem with ogg and mp3
@bigtimebuddy
Copy link
Member Author

The problem is pixi-animate setting audio files to load as <audio> elements. See here. This should be removed since that's the default for audio elements using resource-loader anyways.

This is something added here pixijs/animate#16. I don't think there are consequences for removing it. @ianmcgregor thoughts?

@pawelstan
Copy link

The workaround is to make sure that the

import "pixi-animate";

is called before

import "pixi-sound";

@ianmcgregor
Copy link

Yeah at the time resource-loader didn't have audio extensions set up by default but that has long since been resolved so we can safely remove that. I can submit a PR, unless you're already on it?

@bigtimebuddy
Copy link
Member Author

Could you make the PR? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants