Question

I'm attempting to add sound to my HTML5 game using SoundJS, a free Javascript library (http://www.createjs.com/#!/SoundJS).

I'm testing it out using the most basic sample program that's included in the zip. It runs great when opening in a browser from my hard drive, but after uploading it, no sounds play when I load the page from the web. The sound files are in the exact same place and folder as on my pc.

Has anyone successfully gotten this to work?

Here's what I'm trying to run:

function init()
  {
  if (!createjs.Sound.initializeDefaultPlugins()) {return;}

  var audioPath = "sounds/";
  var manifest = [
    {id:"Music", src:"18-machinae_supremacy-lord_krutors_dominion.ogg"},
    {id:"Thunder", src:"Thunder1.ogg"}
    ];

  createjs.Sound.alternateExtensions = ["mp3"];
  createjs.Sound.addEventListener("fileload", handleLoad);
  createjs.Sound.registerManifest(manifest, audioPath);
  }

function handleLoad(event)
  {
  createjs.Sound.play(event.src);
  }
Was it helpful?

Solution

I work on SoundJS and can confirm it works from servers, as you can see in the examples.

As the above comment says, the best place to start is in developer console in your browser.

Potential sources of the issue are not including or having the wrong path for the js files that are loaded in the script tags, not including / wrong path for the sound files, and possibly but unlikely not setting the correct mime types on your server to properly return audio files.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top