sound: resource does not have a "sound" property

I have try to preload a .mp3 file using PIXI loader with this example: http://pixijs.io/pixi-sound/examples/#section-preloading

The ressource is loaded just fine but there is no “sound” property on it. If I use “data” instead it works:

resources.bird.sound.play(); => does not work resources.bird.data.play(); => does work

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 19 (5 by maintainers)

Most upvoted comments

I solved it, for my own at least.

I had forgotten to require(‘pixi-sound’), after that everything worked smoothly.

I created an example with Webpack +PixiJS v5 + pixi-sound: https://github.com/bigtimebuddy/pixi-sound-webpack-example

Keep in mind, if you’re using chrome, the first thing you play needs to be initiated on a user-interaction event, such as a mouse click. Playing something after it’s been loaded, will not necessarily start playing in some browsers.

Nice to meet you. I am Japanese. I’m sorry if my English is wrong because I use translation.

Does not work unless sound.init() is called first! This works fine if you call it! resources.bird.sound.play(); => does work 😄

yes that fixed the problem. I use the ‘import’ syntax:

import * as pixiSound from 'pixi-sound';

I did not manage to get jsfiddle to load a file, but here is the code: https://jsfiddle.net/vtyp3yyt/7/

if you manage to get past the loading error you should be able to reproduce the issue.