Foros del Web » Creando para Internet » Flash y Actionscript »

no funciona mi reproductor aletorio :(

Estas en el tema de no funciona mi reproductor aletorio :( en el foro de Flash y Actionscript en Foros del Web. Hola a todos! Veran, estoy realizando un reproductor mp3 en actionscript 3 que lee cada cancion desde un archivo xml, lo que sucede es que ...
  #1 (permalink)  
Antiguo 18/09/2011, 17:19
 
Fecha de Ingreso: mayo-2011
Ubicación: aqp
Mensajes: 52
Antigüedad: 13 años
Puntos: 0
no funciona mi reproductor aletorio :(

Hola a todos!
Veran, estoy realizando un reproductor mp3 en actionscript 3 que lee cada cancion desde un archivo xml, lo que sucede es que cada vez que alguien cambia a otra seccion de la página (hace click en algun link dentro de la página) se vuelve a cambiar obviamente el swf del reproductor, y la misma cancion... asi que pense en usar un número aleatorio para cargar una cancion diferente cada vez, pero no he podido, no se como hacer...
cada vez que carga el swf

Código PHP:
volume_mc.slider_mc.useHandCursor true;

var 
musicReq:URLRequest;
var 
music:Sound = new Sound();
var 
sc:SoundChannel;
var 
currentSound:Sound music;
var 
pos:Number;

var 
xml:XML;
var 
songlist:XMLList;
var 
currentIndex:Number 0;

var 
loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETEwhenLoaded);

//Empieza ------------ cual seria el codigo correcto 
function whenLoaded(e:Event):void
{
    
xml = new XML(e.target.data);
    
songlist xml.song;
    
musicReq = new URLRequest(songlist[0].url);
    
music.load(musicReq);
    
sc music.play();
    
title_txt.text songlist[0].title;
    
artist_txt.text songlist[0].artist;
    
sc.addEventListener(Event.SOUND_COMPLETEnextSong);
}
//termina------------ cual seria el codigo correcto 
 

loader.load(new URLRequest("jukebox.xml"));

next_btn.addEventListener(MouseEvent.CLICKnextSong);
prev_btn.addEventListener(MouseEvent.CLICKprevSong);
pause_btn.addEventListener(MouseEvent.CLICK,pauseSong);
play_btn.addEventListener(MouseEvent.CLICK,playSong);
stop_btn.addEventListener(MouseEvent.CLICK,stopSong);

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);
    
sc.stop();
    
title_txt.text songlist[currentIndex].title;
    
artist_txt.text songlist[currentIndex].artist;
    
sc nextTitle.play();
    
currentSound nextTitle;
    
sc.addEventListener(Event.SOUND_COMPLETEnextSong);
}

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);
    
sc.stop();
    
title_txt.text songlist[currentIndex].title;
    
artist_txt.text songlist[currentIndex].artist;
    
sc prevTitle.play();
    
currentSound prevTitle;
    
sc.addEventListener(Event.SOUND_COMPLETEnextSong);
}

function 
pauseSong(e:Event):void
{
    
pos sc.position;
    
sc.stop();
}

function 
playSong(e:Event):void
{
    
sc currentSound.play(pos);
}

function 
stopSong(e:Event):void
{
    
sc.stop();
    
pos 0;
}

//----VOLUME----//
var rect:Rectangle = new Rectangle(0,0,50,0);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragIt);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);
stage.addEventListener(MouseEvent.MOUSE_UP,dropIt);

function 
dragIt(e:Event):void
{
    
e.target.startDrag(false,rect);
    
e.target.addEventListener(MouseEvent.MOUSE_MOVEadjustVolume);
}

function 
dropIt(e:Event):void
{
    var 
vol:Number volume_mc.slider_mc..02;
    var 
st:SoundTransform = new SoundTransform(vol,0);
    
sc.soundTransform st;
    
volume_mc.slider_mc.stopDrag();
    
volume_mc.slider_mc.removeEventListener(MouseEvent.MOUSE_MOVEadjustVolume);
}

function 
adjustVolume(e:Event):void
{
    var 
vol:Number volume_mc.slider_mc..02;
    var 
st:SoundTransform = new SoundTransform(vol,0);
    
sc.soundTransform st;
}

sof_mc.addEventListener(MouseEvent.CLICKplayAd);

function 
playAd(e:Event):void
{
    
ad_mc.play();

Código PHP:
<song>
        <
title>musica1</title>
        <
artist>Musica  </artist>
        <
url>songs/Musica -Instrumental.mp3</url>
</
song

Etiquetas: actionscript, aletorio, reproductor, swf
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:06.