I'm just... trying to get SoundJS to play a sound. It appears that the file never load as my handleLoad function is never called. Any ideas?
var audioPath = "snd/";
var sounds = [
{ id: "mySound", src: "gaia.mp3" }
];
function init( ) {
createjs.Sound.addEventListener( "fileload", handleLoad );
createjs.Sound.registerSounds( sounds, audioPath );
}
function handleLoad( event ) {
console.log( "Hello from handleLoad" );
}
I get a "creates.Sound.registerSounds is not a function" error when init runs.
Your demo should work.
I copied your code into a JSFiddle, and pointed it at a sound that I know exists.https://jsfiddle.net/lannymcnie/vj8rLghb/
The only difference is I added the 3rd parameter because it is being loaded cross-domain
Additionally, changes in Chrome mean that audio can't play without a user interaction, so once the audio is loaded, I added a document-click listener so it plays when you click the page anywhere.
Can you post the full error you get in the console? It is unclear if
registerSounds
is undefined, or if it doesn't exists onundefined
, which indicates thatcreatejs.Sound
is undefined. Have you ensured that SoundJS is included properly? Try putting this in the console:Hope that helps!