# Next track in music player?

**URL:** <https://forum.kirupa.com/t/next-track-in-music-player/185028>\
**Category:** Uncategorized\
**Created:** [April 10, 2006, 1:17pm UTC](https://forum.kirupa.com/t/next-track-in-music-player/185028 "2006-04-10T13:17:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fr33m4n](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@Fr33m4n](https://forum.kirupa.com/u/Fr33m4n)\
**Post date:** [April 10, 2006, 1:17pm UTC](https://forum.kirupa.com/t/next-track-in-music-player/185028/1 "2006-04-10T13:17:33Z")

</div>

Hi guys. I’m trying to build a music player that has multiple songs it can play. It should be fairly simple with next and previous buttons. I’m trying to get it to load a song based on an array I have created. Everything works fine with only one track but I’m unsure how to add more tracks. This is what I’ve done so far:

```auto

stop();

// --------------------------<load and loop sound>-------------------------- \\
this.createTextField("status_txt", this.getNextHighestDepth(), 72,630,100,22);

// create a new Sound object
var my_sound:Sound = new Sound();
musictext.text = "loading";
// if the sound loads, play it; if not, trace failure loading
my_sound.onLoad = function(success:Boolean) {
if (success) {
my_sound.start();
musictext.text = "music on";
} else {
status_txt.text = "Sound failed";
}
};
/* Experimental
var soundUrls:Array = ['Navn1']
switchTrack = function (trackNr) {
my_sound.stop();
my_sound.loadSound(soundUrls[trackNr]);
}*/
// load the sound

var songnr:Array = ['song0']
for (var i = 0; i<songnr.length; i++)
switchTrack = function() {
my_sound.loadSound("song"+i+".mp3", true);
trace(i);
}
// loop the sound
my_sound.onSoundComplete = function() {
my_sound.start();
};

// --------------------------</load and loop sound>-------------------------- \\

// ------------------------------<Play Stop button function>------------------------------ \\
var playstat:String
playstat = 'on'
control.onRelease = function () {
    if (playstat != 'off') {
        gotoAndStop(2);
        playstat = 'off';
        my_sound.stop();
        musictext.text = "music off";
        //trace (playstat);
    }
    else if (playstat != 'on') {
        gotoAndStop(1);
        playstat = 'on';
        my_sound.start();
        musictext.text = "music on";
        this.switchTrack();
        //trace (playstat);
        trace(songnr);
    }
}
switchTrack();
// ------------------------------</Play Stop button function>------------------------------ \\

```

Yeah I know, it’s probably the worst mp3 player in history but I’m kinda new to this so I would grately appriciate any help. thx in advance.

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 10, 2006, 9:26pm UTC](https://forum.kirupa.com/t/next-track-in-music-player/185028/2 "2006-04-10T21:26:06Z")

</div>

[‘song0’]

add more songs:

```auto

['song0', 'song1']

```

for example.
