Comunidad de diseño web y desarrollo en internet online

Botones next y prev para componente List en repro. de mp3

Citar            
MensajeEscrito el 27 Dic 2009 06:41 pm
Hola gente, alguien me puede ayudar explicandome como puedo hacer para poner botones de "siguiente" y "anterior" en un reproductor de mp3 que funciona con el componente List y que carga los mp3 desde un xml.

Que codigos le tengo que poner??? soy bastante novato en esto y ya a esta altura del año mi cerebo no funciona del todo bien. Es un ejemplo que encontre por internet (en la firma de un usuaio de este foro http://www.flash-db.com/Tutorials/mp3player/ ) y los codigos que tiene en los botones que hay son de play y pause nomas. El diseño ya lo modifique lo que me gustaria es poder cambiar de cancion con los botones ademas de con la lista.

Código ActionScript :

//controls
var soundPosition:Number;
var paused:Boolean = false;

controlbar_mc.pause_btn.onRelease = function():Void{
   soundPosition = mySound.position;
   paused = true;
   mySound.stop();
}

controlbar_mc.play_btn.onRelease = function():Void{
   if(paused){
   mySound.start(soundPosition/1000);
   paused = false;
   }
}

Por marianitten

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 28 Dic 2009 01:41 pm
Dado que supongo que soy el de la firma, lo que necesitas sería algo así:

Código ActionScript :

//siguiente
controlbar_mc.bot_siguiente.onPress = function(){
    if (list_comp.selectedIndex<(totalTracks-1)) {
      list_comp.selectedIndex += 1;
    } else {
      list_comp.selectedIndex = 0;
   }  
   playTrack(tracks_array[list_comp.selectedIndex].source,tracks_array[list_comp.selectedIndex].artist,tracks_array[list_comp.selectedIndex].album,tracks_array[list_comp.selectedIndex].title,true);
};
//anterior
controlbar_mc.bot_anterior.onPress = function(){
    if (list_comp.selectedIndex>0) {
      list_comp.selectedIndex -= 1;
    } else {
      list_comp.selectedIndex = (totalTracks-1);
   }  
   playTrack(tracks_array[list_comp.selectedIndex].source,tracks_array[list_comp.selectedIndex].artist,tracks_array[list_comp.selectedIndex].album,tracks_array[list_comp.selectedIndex].title,true);
};


Fijate que bot_siguiente y bot_anterior están dentro de controlbar_mc, que es el clip que contiene los botones

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 28 Dic 2009 06:04 pm
Muchas gracias, funciono de maravillas.

Impecable señor.

Gracias nuevamente.

Por marianitten

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 04 Ene 2010 05:38 am
hola te envió uno que me funciona a mi es con xml todo dentro de un clip de película espero te sirva y me aviasas

este es AS3 que va en el reproductor

Código ActionScript :


var getMusic:URLRequest;
var music:Sound = new Sound();
var soundChannel:SoundChannel;
var currentSound:Sound = music;
var pos:Number;
var currentIndex:Number = 0;
var songPlaying:Boolean = false;
var xml:XML;
var songlist:XMLList;






function loadProgress(event:ProgressEvent):void {
    var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
    percentLoaded = Math.round(percentLoaded * 100);
   if(percentLoaded > 20){
      trace("loading");
   } else{
   }
}

function completeHandler(event):void {
    trace("DONE");
   }



var loader:URLLoader = new URLLoader(); 
loader.addEventListener(Event.COMPLETE, whenLoaded); 
loader.load(new URLRequest("songs.xml")); 

function whenLoaded(e:Event):void 
{
   xml = new XML(e.target.data); 
   songlist = xml.song; 
   getMusic = new URLRequest(songlist[0].url);
   music.load(getMusic);//load music
   soundChannel = music.play();
   songTXT.text = songlist[0].title; 
   artistTXT.text = songlist[0].artist; 
   albumTXT.text = songlist[0].album;  
   
   soundChannel.addEventListener(Event.SOUND_COMPLETE, nextSong);
}





next_btn.addEventListener(MouseEvent.CLICK, nextSong); 
prev_btn.addEventListener(MouseEvent.CLICK, prevSong);
pause_btn.addEventListener(MouseEvent.CLICK,pauseSong);



function nextSong(e:Event):void
{
   if (currentIndex < (songlist.length() - 1))
   {
      currentIndex++;
   }
   else
   {
      currentIndex = 0;
   }

   var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url);
   var nextTitle:Sound = new Sound(nextReq);
   soundChannel.stop();
   songTXT.text = songlist[currentIndex].title;
   artistTXT.text = songlist[currentIndex].artist;
   albumTXT.text = songlist[currentIndex].album;
   soundChannel = nextTitle.play();
   songPlaying = true;
   currentSound = nextTitle;
   soundChannel.addEventListener(Event.SOUND_COMPLETE, nextSong);
}



function prevSong(e:Event):void
{
   if (currentIndex > 0)
   {
      currentIndex--;
   }
   else
   {
      currentIndex = songlist.length() - 1;
   }

      
   var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url);
   var prevTitle:Sound = new Sound(nextReq);
   soundChannel.stop();
   songTXT.text = songlist[currentIndex].title;
   artistTXT.text = songlist[currentIndex].artist;
   albumTXT.text = songlist[currentIndex].album;
   soundChannel = prevTitle.play();
   songPlaying = true;
   currentSound = prevTitle;
   soundChannel.addEventListener(Event.SOUND_COMPLETE, nextSong);
}

function pauseSong(e:Event):void
{
   pos = soundChannel.position; 
   soundChannel.stop(); 
   songPlaying = false; 
   play_btn.addEventListener(MouseEvent.CLICK,playSong); 
}

function playSong(e:Event):void
{
   if(songPlaying == false) 
   {
      soundChannel = currentSound.play(pos); 
      soundChannel.addEventListener(Event.SOUND_COMPLETE, nextSong);
      songPlaying = true;
      play_btn.removeEventListener(MouseEvent.CLICK,playSong);
   }
}



ahora creas un xml con la lista de canciones que quieres no olvides cambiar los titulos estas son de una web qe hice hace rato los archivos mp3 creas una carpeta llamada" songs"

Código XML :

<?xml version="1.0" encoding="ISO-8859-1"?>
<ipod>

   <song>
      <title>Tu pureza</title>
      <artist>Felipe Gómez</artist>
      <album>La vida</album>
      <url>songs/track1.mp3</url>
   </song>
   <song>
      <title>San José carpintero</title>
      <artist>Felipe Gómez</artist>
      <album>La vida</album>
      <url>songs/track2.mp3</url>
   </song>
   <song>
      <title>La vida</title>
      <artist>Felipe Gómez</artist>
      <album>La vida</album>
      <url>songs/track5.mp3</url>
   </song>
   
   
</ipod>


si quieres verlo funcionando
entra a
www.bajotumanto.com

Por juanzear

36 de clabLevel



 

chrome
Citar            
MensajeEscrito el 04 Ene 2010 05:40 am
lo olvidaba tienes que crear tres textos diamnicos para el titulo album y autor si quieres te envio un archivo de ejemplo

Por juanzear

36 de clabLevel



 

chrome

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.