# Problems with looping tracks with XML mp3 player

**URL:** <https://forum.kirupa.com/t/problems-with-looping-tracks-with-xml-mp3-player/177264>\
**Category:** flash\
**Created:** [January 31, 2006, 4:47pm UTC](https://forum.kirupa.com/t/problems-with-looping-tracks-with-xml-mp3-player/177264 "2006-01-31T16:47:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thirdworldman](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@thirdworldman](https://forum.kirupa.com/u/thirdworldman)\
**Post date:** [January 31, 2006, 4:47pm UTC](https://forum.kirupa.com/t/problems-with-looping-tracks-with-xml-mp3-player/177264/1 "2006-01-31T16:47:56Z")

</div>

I recently found a GREAT tutorial on creating a simple xml based mp3 player. You can download the source files here: [http://site.inmod.com/flash/playerfixed.zip](http://site.inmod.com/flash/playerfixed.zip)

However, I’m having a problem since I have a very limited understanding of actionscript. Can someone please tell me how to alter the actionscript code so that the player continuously cycles through the playlist, rather than just playing the song once? I altered the actionscript a little to fit my project–see below:

playlist = new XML();  
playlist.ignoreWhite = true;  
playlist.onLoad = function(success) {  
if (success) {  
\_global.songname = [];  
\_global.songband = [];  
\_global.songfile = [];  
for (var i = 0; i\<playlist.firstChild.childNodes.length; i++) {  
\_global.songname\* = playlist.firstChild.childNodes\*.attributes.name;  
\_global.songfile\* = playlist.firstChild.childNodes\*.attributes.file;  
trace(songname\*+" "+songfile\*);  
}  
}  
\_root.mp3.createEmptyMovieClip(“sound\_mc”, 1);  
\_root.mp3.sound\_mc.sound\_obj = new Sound();  
\_global.song\_nr = random(songfile.length);  
\_root.mp3.sound\_mc.songStarter(songfile[song\_nr], songname[song\_nr]);  
};  
MovieClip.prototype.songStarter = function(file, name) {  
this.soun! d\_obj.loadSound(file, true);  
this.onEnterFrame = function() {  
if (this.sound\_obj.position\>0) {  
delete this.onEnterFrame;  
this.\_parent.display\_txt.text = name;  
} else {  
this.\_parent.display\_txt.text = “loading…”;  
}  
};  
this.sound\_obj.onSoundComplete = function() {  
(song\_nr == songfiles.length-1) ? \_global.song\_nr=0 : \_global.song\_nr++;  
\_root.mp3.sound\_mc.songStarter(songfiles[song\_nr], songname[song\_nr]);  
};  
};  
btn\_play.onRelease = function() {  
this.\_parent.sound\_mc.songStarter(songfile[song\_nr], songname[song\_nr]);  
};  
btn\_stop.onRelease = function() {  
this.\_parent.sound\_mc.sound\_obj.stop();  
};  
btn\_fw.onRelease = function() {  
(song\_nr == songfile.length-1) ? \_global.song\_nr=0 : \_global.song\_nr++;  
\_root.mp3.sound\_mc.songStarter(songfile[song\_nr], so! ngname[song\_nr]);  
};  
btn\_rev.onRelease = function() {  
(song\_nr == 0) ? \_global.song\_nr=songfile.length-1 : \_global.song\_nr–;  
\_root.mp3.sound\_mc.songStarter(songfile[song\_nr], songname[song\_nr]);  
};  
playlist.load(“playlist.xml”);
