Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

9 years ago by Lawn

Hi,

I receive the following error when I attempt to add background music to my project:

Uncaught TypeError: undefined is not a function

The error occurs on line 86 of sound.js - that line looks like this:
loadCallback( path, true, ev );

This error occurs on both Chrome and Firefox.

I am using the jumpnrun example as a template. Here is the code in question:
init: function() {
// Sound
var musicIntro = new ig.Sound( 'media/music/intro.*' );
musicIntro.loop = true;
musicIntro.volume = 0.5;
musicIntro.play();

I have intro.ogg and intro.mp3 files in the media/music/ directory. If I use a shorter audio file (like a sound effect), then it works as expected. The error only occurs if I use a longer audio file like a song.

9 years ago by Joncom

I think you may be trying to play() the audio before it has had time to load.

You should pre-load audio assets instead of loading them on-the-fly.

musicIntro: new ig.Sound('media/music/intro.*'),
init: function() {
    this.musicIntro.loop = true;
    this.musicIntro.volume = 0.5;
    this.musicIntro.play();
}
Page 1 of 1
« first « previous next › last »