Tal vez puedan ayudarme, estoy haciendo un mp3 player que funciona correctamente como va hasta el momento, pero
hay unas cosillas que no he podido hacer, me gustaria guiaran en lo siguiente:
1. Quiero que el boton play/pause sean el mismo, es decir que se transforme al oprimirlo y cumpla su respectiva funcion, tengo un mc con dos fotogramas: play y pause.
Lo mismo para el mc volumen: con volumen y sin volumen.
2. Cuando llega a la ultima cancion el reproductor se detiene, ¿Como hago para que se reproduzca en bucle? que al acabar la ultima cancion comienze la primera...
Adjunto mi AS
Gracias Muchachos!!!!
Código ActionScript :
package clases{
   //
   import flash.display.Loader;
   import flash.net.URLLoader;
   import flash.net.URLRequest;
   import flash.media.Sound;
   import flash.media.SoundChannel;
   import flash.events.MouseEvent;
   import flash.media.SoundLoaderContext;    
   
   public class Main extends MovieClip{
      
      private var musicReq: URLRequest;   
       private var music:Sound = new Sound();  
       private var sndC:SoundChannel;  
       private var currentSnd:Sound = music;  
       private var position:Number;  
       private var currentIndex:Number = 0;  
       private var songPaused:Boolean;  
       private var songStopped:Boolean;  
      private var changeClr:Boolean;  
       private var xml:XML;  
       private var songList:XMLList;  
       private var loader:URLLoader = new URLLoader(); 
      private var context:SoundLoaderContext = new SoundLoaderContext(30000, false); 
       
      public function Main(){
         
         //mp3 botones
         mp3player_mc.prev_mc.addEventListener(MouseEvent.CLICK, prevSong);
         mp3player_mc.next_mc.addEventListener(MouseEvent.CLICK, nextSong);
         mp3player_mc.play_mc.addEventListener(MouseEvent.CLICK, playSong);
         mp3player_mc.stop_mc.addEventListener(MouseEvent.CLICK, stopSong);
         
         loader.addEventListener(Event.COMPLETE, Loaded);  
              loader.load(new URLRequest("xml/music.xml"));
      }
      
      //mp3 player
        private function Loaded(e:Event):void{  
          xml = new XML(e.target.data);  
          songList = xml.song;  
          musicReq = new URLRequest(songList[0].url);
          music.load(musicReq, context);  
          sndC = music.play();  
        mp3player_mc.title_txt.text = songList[0].title;
           sndC.addEventListener(Event.SOUND_COMPLETE, nextSong);
      } 
      
        private function prevSong(e:Event):void{  
            if(currentIndex > 0){  
               currentIndex--;
            }
            else{  
              currentIndex = songList.length() - 1;  
             }  
         var prevReq:URLRequest = new URLRequest(songList[currentIndex].url);  
         var prevPlay:Sound = new Sound(prevReq, context);
            sndC.stop();  
            mp3player_mc.title_txt.text = songList[currentIndex].title;    
            sndC = prevPlay.play();  
            currentSnd = prevPlay;  
           // songPaused = false;   
          sndC.addEventListener(Event.SOUND_COMPLETE, nextSong);  
       } 
       
        private  function nextSong(e:Event):void {  
            if(currentIndex < (songList.length() - 1)){  
                 currentIndex++;  
            }  
                else {  
               currentIndex = 0;
             }  
         var nextReq:URLRequest = new URLRequest(songList[currentIndex].url);  
       var nextPlay:Sound = new Sound(nextReq, context);
         sndC.stop();  
         mp3player_mc.title_txt.text = songList[currentIndex].title;   
         sndC = nextPlay.play();  
          currentSnd = nextPlay;  
        // songPaused = false;  
         sndC.addEventListener(Event.SOUND_COMPLETE, nextSong);
       }
       
        private function playSong(e:Event):void{
          if(songPaused){
             sndC = currentSnd.play(position);
             //songPaused = false;
             }  
              else if(songStopped){  
                  sndC = currentSnd.play(position);  
                  songStopped = false;  
             }  
            else if(!sndC){  
           sndC = currentSnd.play(position);
         }
         }
         
        private function stopSong(e:Event):void{
           sndC.stop();  
             position = 0;  
              songStopped = true;
           }   
   }
}
   
					