# Starting next sound when sound is done

**URL:** <https://forum.kirupa.com/t/starting-next-sound-when-sound-is-done/117499>\
**Category:** Uncategorized\
**Created:** [July 27, 2004, 11:21pm UTC](https://forum.kirupa.com/t/starting-next-sound-when-sound-is-done/117499 "2004-07-27T23:21:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenu](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/chenu/32/562_2.png) [@chenu](https://forum.kirupa.com/u/chenu)\
**Post date:** [July 27, 2004, 11:21pm UTC](https://forum.kirupa.com/t/starting-next-sound-when-sound-is-done/117499/1 "2004-07-27T23:21:12Z")

</div>

Hi Everyone,  
I have 3 tracks as background music for my site. I’m using this script to play them and to fastforward.

```auto
mp3path = "http://2-cubed.net/v2/audio/";
 music = ["track1.mp3", "track2.mp3", "track3.mp3"];
 t = 0;
 function loadTrack(t) {
 	song = new Sound(this);
 	song.loadSound(mp3path+music[t], 999);
 }
 nextBut.onRelease = function() {
 	t<music.length-1 ? t++ : t=0;
 	loadTrack(t);
 };
 loadTrack(t);

```

Now i’m wondering what would i have to do to automatically go to the next track when track 1 is done.

I was trying this code but i’m not sure if it works.

```auto
song.onSoundComplete = function(){//
 // soundobject.start(secondsoffset,loops);
 	t<music.length-1 ? t++ : t=0;
 	loadTrack(t);
 }

```
