# Stop music playing Audio Player automatically

**URL:** https://forum.kirupa.com/t/stop-music-playing-audio-player-automatically/310806
**Category:** flash
**Created:** [June 19, 2010, 10:06pm UTC](https://forum.kirupa.com/t/stop-music-playing-audio-player-automatically/310806 "2010-06-19T22:06:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![adam\_fake](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@adam\_fake](https://forum.kirupa.com/u/adam_fake)
#### Post date: [June 19, 2010, 10:06pm UTC](https://forum.kirupa.com/t/stop-music-playing-audio-player-automatically/310806/1 "2010-06-19T22:06:48Z")

</div>

I’m by no means up on my AS at all and this MP3 player i’ve had for a while and just readjusted to suit my needs.

One thing i really want to change is the fact the music starts automatically. I changed line 38 from True to False which does indeed stop the music playing on load but instead i get “Loading” and it doesn’t do anything after that. Hitting play won’t work.

Any suggestions would be really appreciated. 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.songband* = playlist.firstChild.childNodes*.attributes.band;
             _global.songfile* = playlist.firstChild.childNodes*.attributes.file;
             //trace(songname*+" "+songfile*+" "+songband*);
        }
     }
    _root.createEmptyMovieClip("sound_mc", 1);
     _global.song_nr = random(songfile.length);
     _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
function timer(sound_obj) {
    time = sound_obj.position/1000;
    min = Math.floor(time/60);
    min = (min<10) ? "0"+min : min;
    sec = Math.floor(time%60);
     sec = (sec<10) ? "0"+sec : sec;
    timeDisplay_txt.text = min+":"+sec;
}
MovieClip.prototype.songStarter = function(file, name, band) {
    if (this.sound_obj) {
         this.sound_obj.stop();
        delete this.sound_obj;
    }
     this.sound_obj = new Sound(this);
    this.sound_obj.loadSound(file, true);
    this.onEnterFrame = function() {
        if (this.sound_obj.position>0) {
            delete this.onEnterFrame;
             this._parent.title_mc.displayTxtHolder_mc.display_txt.text = name+" - "+band;
            timeInterval = setInterval(timer, 1000, this.sound_obj);
        } else {
             this._parent.title_mc.displayTxtHolder_mc.display_txt.text = "loading...";
        }
    };
     this.sound_obj.onSoundComplete = function() {
         clearInterval(timeInterval);
         this._parent.timeDisplay_txt.text = "00:00";
        (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
         _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
    };
     this._parent.volume1.dragger.onPress = function() {
         startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y);
         this.onEnterFrame = function() {
            var p = (this._x/this._parent.volBG._width)*100;
             this._parent._parent.sound_mc.sound_obj.setVolume(p);
        };
     };
    this._parent.volume1.dragger.onRelease = function() {
         delete this.onEnterFrame;
        stopDrag();
    };
     this._parent.volume1.dragger.onReleaseOutside = function() {
         stopDrag();
    };
};
btn_play.onRelease = function() {
     this._parent.title_mc.gotoAndPlay(1);
     clearInterval(timeInterval);
    this._parent.timeDisplay_txt.text = "00:00";
    this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
btn_stop.onRelease = function() {
    this._parent.title_mc.gotoAndStop(112);
     clearInterval(timeInterval);
    this._parent.timeDisplay_txt.text = "00:00";
    this._parent.sound_mc.sound_obj.stop();
};
btn_fw.onRelease = function() {
    this._parent.title_mc.gotoAndPlay(1);
     clearInterval(timeInterval);
    this._parent.timeDisplay_txt.text = "00:00";
    (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
    _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
    
};
btn_rev.onRelease = function() {
    this._parent.title_mc.gotoAndPlay(1);
     clearInterval(timeInterval);
    this._parent.timeDisplay_txt.text = "00:00";
    (song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
    _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
playlist.load("playlist.xml");

```
