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

1 decade ago by FragDoctor

I'm just getting to grips with ImpactJS - massively impressed with it so far.

I'm in a position where I would like to be able to play several sounds one after the other in sequence. So if I have:

SoundA.mp3
SoundB.mp3
SoundC.mp3

I'd like to queue them one after the other so that SoundA.mp3 plays, immediately following by SoundB.mp3 and then SoundC.mp3 - all one after the other.

An alternative would be if I could detect when one sound finishes playing so that I could then play the next one myself.

It's not an option to edit them all together in advance.

Does anyone know either:

1) How to queue sounds, or
2) How to detect whether a sound has finished playing

Any help is much appreciated.

1 decade ago by stahlmanDesign

You can use the ig.Music instance automatically created in main.js to play sounds in sequence. Here's how I do it:

In main.js:

themeSong: new ig.Sound("media/ds_theme.mp3", false),
slowSong: new ig.Sound("media/ds_slow.mp3", false),
…

init: function() {
		ig.music.add(this.themeSong);
		ig.music.add(this.slowSong);
		//this.themeSong.play();
		ig.music.play();
},
...

When the first song is done, the second one will start. You can also jump to different songs I think like this:

ig.music.currentIndex = 1;
ig.music.play();

1 decade ago by FragDoctor

Thanks - that's precisely what I was after and it worked perfectly!
Page 1 of 1
« first « previous next › last »