3 Replies Latest reply on Nov 19, 2007 5:23 PM by kglad

    mp3 player

    P_e_r_o
      Hello!

      I have a problem with my mp3 player. It loads songs thru xml. It has four buttons: play, pause, next and mute.
      I have five songs in my folder. The problem is, when I press the next button a couple of times to go to song 5 It starts loading all five songs and it slows my site down. I want it to load just the song I am listening too.

      Please help!
      Thanks!
        • 1. Re: mp3 player
          kglad Adobe Community Professional & MVP
          oh, i see you have a coding problem.
          • 2. Re: mp3 player
            P_e_r_o Level 1
            It loads mp3s over and over again, I would like that it loads just the song you are listening to.
            this is the code of my mp3 player:

            //setup sound object
            var s:Sound = new Sound();
            s.onSoundComplete = playSong;
            s.setVolume(75);

            //Array of songs
            var sa:Array = new Array();

            //Currently playing song
            var cps:Number = -1;

            //Current volume
            var cv:Number = 75;

            //Load the songs XML
            var xml:XML = new XML();
            xml.ignoreWhite = true;
            xml.onLoad = function(){
            var nodes:Array = this.firstChild.childNodes;
            for(var i=0;i<nodes.length;i++){
            sa.push(new Song(nodes .attributes.url, nodes.attributes.artist, nodes .attributes.track));
            }
            playSong();
            }

            xml.load("songs.xml");

            //Play the MP3 file


            function playSong():Void {
            s = new Sound();
            s.onSoundComplete = playSong;

            mute.gotoAndStop("on");
            if (cps == sa.length-1) {
            cps = 0;
            s.loadSound(sa[cps].earl, true);
            } else {
            s.loadSound(sa[++cps].earl, true);
            }
            s.setVolume(cv);
            infoTrack.text = sa[cps].artist + " - " + sa[cps].track;
            playPause.gotoAndStop("pause");
            }
            //pause the music

            function pauseIt():Void{
            pos = s.position;
            s.stop();
            }

            //unpause the music

            function unPauseIt():Void{
            s.start(pos/1000);
            }


            //Next button
            next.onRollOver = function(){
            this.gotoAndStop("nextOver");
            }

            next.onRollOut = next.onReleaseOutside = function(){
            this.gotoAndStop("next");
            }

            next.onRelease = function(){
            playSong();
            }

            //postion of music
            var pos:Number;


            //-------playPause toggle
            playPause.onRollOver = function(){
            if(this._currentframe == 1){
            this.gotoAndStop("pauseOver");
            }else{
            this.gotoAndStop("playOver");
            }

            }//playPause.onRollOver

            playPause.onRollOut = function(){
            if(this._currentframe == 10){
            this.gotoAndStop("pause");
            }else{
            this.gotoAndStop("play");
            }

            }//playPause.onRollOver

            playPause.onRelease = function(){
            if(this._currentframe == 10){
            this.gotoAndStop("playOver");
            pauseIt();
            }else{
            this.gotoAndStop("pauseOver");
            unPauseIt();
            }

            }//playPause.onRelease

            //-------Audio Controls
            //-------muteSoundOn toggle
            muteSoundOn.onRollOver = function(){
            if(this._currentframe == 1){
            this.gotoAndStop("onOver");
            }else{
            this.gotoAndStop("offOver");
            }

            }//muteSoundOn.onRollOver

            muteSoundOn.onRollOut = muteSoundOn.onReleaseOutside = function(){
            if(this._currentframe == 10){
            this.gotoAndStop("on");
            }else{
            this.gotoAndStop("off");
            }

            }//muteSoundOn.onRollOver

            muteSoundOn.onRelease = function(){
            if(this._currentframe == 10){
            this.gotoAndStop("offOver");
            volScrub._xscale = 0;
            s.setVolume(0);
            cv = 0;
            //trace(cv);
            }else{
            this.gotoAndStop("onOver");
            volScrub._xscale = 75;
            s.setVolume(75);
            cv = 75;
            //trace(cv);
            }

            }//muteSoundOn.onRelease
            • 3. Re: mp3 player
              kglad Adobe Community Professional & MVP
              use the trace() function to narrow your problem. then if you're having trouble, use the attach code option to copy and paste just the relevant portion of your code.