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 mimik

Hello
Search the forum and cant really find anything about playing random order of music.

		ig.musicSecondary = new ig.Music();
		ig.musicSecondary.random;
		ig.musicSecondary.add('media/beats/m1.mp3');
		ig.musicSecondary.add('media/beats/m2.mp3');
		ig.musicSecondary.add('media/beats/m3.mp3');

How do i play a random track?
I want it to randomize the tracks in there

i can shuffle the array ig.musicSecondary.tracks
and the array gets shuffled but the first song always plays.

1 decade ago by dominic

Did you miss a = true; to set it to randomized order? And you have to call .next() once, otherwise the currentTrack will be the first one you added.

ig.musicSecondary = new ig.Music();
ig.musicSecondary.random = true;
ig.musicSecondary.add('media/beats/m1.mp3');
ig.musicSecondary.add('media/beats/m2.mp3');
ig.musicSecondary.add('media/beats/m3.mp3');

ig.musicSecondary.next(); // begin playing random track

1 decade ago by mimik

Oh thank you!
Had some trouble with that first song indeed!

Calling next would solve it. :-)
Thanks!
Page 1 of 1
« first « previous next › last »