# XML mp3 Player Simple Problem

**URL:** <https://forum.kirupa.com/t/xml-mp3-player-simple-problem/214439>\
**Category:** flash\
**Created:** [January 29, 2007, 2:26am UTC](https://forum.kirupa.com/t/xml-mp3-player-simple-problem/214439 "2007-01-29T02:26:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ygramul](https://avatars.discourse-cdn.com/v4/letter/y/7993a0/32.png) [@Ygramul](https://forum.kirupa.com/u/Ygramul)\
**Post date:** [January 29, 2007, 2:26am UTC](https://forum.kirupa.com/t/xml-mp3-player-simple-problem/214439/1 "2007-01-29T02:26:25Z")

</div>

Hi guys. I just need a little help altering this code so that the songs loop. Once the XML playlist ends it doesn’t go back to the beginning. Once the playlist ends it needs to go back to the beginning and start over (loop).

Can someone please help? Thanks!

```auto

stop();
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;
        }
    }
    _root.createEmptyMovieClip("sound_mc", 1);
    _root.sound_mc.sound_obj = new Sound();
    _global.song_nr = random(songfile.length);
    _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
MovieClip.prototype.songStarter = function(file, name) {
    this.sound_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.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();
};

playlist.load("sound.xml");

```
