Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Tenho um player em flash que puxa as musicas em arquivo XML, tá tudo funcionando beleza.
Quero agora inserir 4 botões (Funk, pagode, mpb e rock), queria que quando o usuário clicasse, carregasse o arquivo xml funk.xml por exemplo.
O codigo atual que puxa o xml é:
>
onClipEvent (load)
{
function player(elmMain)
{
this.elmMain = elmMain;
this.elmMain.xmlRetorno;
this.elmMain.numMusica;
this.elmMain.musicaAtual;
this.elmMain.musicaCorrente;
this.elmMain.musicaCorrenteShuffle;
this.elmMain.playList1 = new Array();
this.elmMain.playList2 = new Array();
this.elmMain.playList3 = new Array();
this.elmMain.playList4 = new Array();
this.elmMain._soundbuftime = 10;
this.elmMain.playSound = new Sound();
this.elmMain.playSound.setVolume(100);
this.elmMain.elmTextProxMusica.html = true;
this.elmMain.elmTextProxMusica2.html = true;
this.elmMain.elmInfoMusica.elmTextMusica.html = true;
this.elmMain.pausa;
this.elmMain.inicioSequencia;
this.elmMain.sequenciaShuffe;
this.elmMain.shuffle;
this.elmMain.indicaPlayList;
this.elmMain.indicaPlayListSong;
this.elmMain.onEnterFrame = function ()
{
if (!shufle)
{
indicaPlayList = "3";
indicaPlayListSong = "4";
}
else
{
indicaPlayList = "1";
indicaPlayListSong = "2";
} // end else if
};
this.elmMain.playSound.onSoundComplete = function ()
{
nextMusica();
};
this.duracao = function ()
{
this.elmMain.elmDuracao.elmIcoDuracao._x = playSound.position / playSound.duration * 270;
trace (this.elmMain.elmDuracao.elmIcoDuracao._x);
if (this.elmMain.elmDuracao.elmIcoDuracao._x >= 269 && playSound.duration > 90000)
{
this.elmMain.elmDuracao.elmIcoDuracao._x = 0;
nextMusica();
} // end if
};
System.useCodepage = true;
var playerXML = new XML();
playerXML.load("config.xml");
playerXML.ignoreWhite = true;
playerXML.onLoad = function ()
{
PlayList(this);
};
PlayList = function (objeto)
{
xmlRetorno = objeto;
numMusica = xmlRetorno.childNodes[0].childNodes.length;
for (i = 0; i < numMusica; i++)
{
playList1 = new Array();
playList3 = new Array();
} // end of for
for (cont1 = 0; cont1 < numMusica; cont1++)
{
for (cont2 = 0; cont2 < 3; cont2++)
{
playList1[cont1][cont2] = xmlRetorno.childNodes[0].childNodes[cont1].childNodes[cont2].childNodes;
} // end of for
} // end of for
this.organizaPlayListShuffle();
this.organizaPlayList();
this.playMusica();
};
organizaPlayListShuffle = function ()
{
for (cont1 = 0; cont1 < numMusica; cont1++)
{
sequenciaShuffe = int(Math.random() * numMusica);
for (cont2 = 0; cont2 < 3; cont2++)
{
playList3[cont1][cont2] = playList1[sequenciaShuffe][cont2];
} // end of for
} // end of for
};
organizaPlayList = function ()
{
for (cont1 = 0; cont1 < numMusica; cont1++)
{
playList2[cont1] = playList1[cont1][2];
playList4[cont1] = playList3[cont1][2];
} // end of for
inicioSequencia = Math.round(Math.random() * numMusica);
musicaAtual = inicioSequencia;
musicaCorrenteSuffle = eval("playList" + indicaPlayListSong);
musicaCorrente = musicaCorrenteSuffle[musicaAtual];
};
this.proximaMusica = function ()
{
nextMusica();
};
nextMusica = function ()
{
this.MusicaAtual2 = musicaAtual + 1;
this.indicadorMusica = playList2[MusicaAtual2];
if (this.indicadorMusica != undefined)
{
++musicaAtual;
musicaCorrenteSuffle = eval("playList" + indicaPlayListSong);
musicaCorrente = musicaCorrenteSuffle[musicaAtual];
}
else
{
musicaAtual = 0;
musicaCorrenteSuffle = eval("playList" + indicaPlayListSong);
musicaCorrente = musicaCorrenteSuffle[musicaAtual];
} // end else if
playMusica();
};
this.anteriorMusica = function ()
{
previusMusica();
};
previusMusica = function ()
{
this.MusicaAtual2 = musicaAtual - 1;
this.indicadorMusica = playList2[MusicaAtual2];
if (this.indicadorMusica == undefined)
{
musicaAtual = 0;
musicaCorrenteSuffle = eval("playList" + indicaPlayListSong);
musicaCorrente = musicaCorrenteSuffle[musicaAtual];
playMusica();
}
else
{
--musicaAtual;
musicaCorrenteSuffle = eval("playList" + indicaPlayListSong);
musicaCorrente = musicaCorrenteSuffle[musicaAtual];
playMusica();
} // end else if
};
this.pauseMusica = function ()
{
playSound.stop();
};
this.playMusica2 = function ()
{
playSound.start();
};
this.stopMusica = function ()
{
pararMusica();
};
pararMusica = function ()
{
musicaAtual = 0;
musicaCorrenteSuffle = eval("playList" + indicaPlayListSong);
musicaCorrente = musicaCorrenteSuffle[musicaAtual];
playMusica();
playSound.stop();
};
this.controlaShuffle = function ()
{
if (shufle)
{
shufle = false;
}
else
{
shufle = true;
} // end else if
};
playMusica = function ()
{
this.proxTextMusica = musicaAtual + 1;
this.indicadorMusica = playList1[this.proxTextMusica][0];
this.testando = eval("playList" + indicaPlayList);
trace (testando);
elmInfoMusica.elmTextMusica.htmlText = "<b>Artista: </b>" + this.testando[musicaAtual][1] + " / <b>Música: </b>" + this.testando[musicaAtual][0];
if (this.indicadorMusica != undefined)
{
elmTextProxMusica.htmlText = "<b>Próxima música > Artista: </b>" + this.testando[this.proxTextMusica][1];
elmTextProxMusica2.htmlText = "<b>Música: </b>" + this.testando[this.proxTextMusica][0];
}
else
{
elmTextProxMusica.htmlText = "";
elmTextProxMusica2.htmlText = "";
} // end else if
playSound = new Sound();
playSound.loadSound(musicaCorrente, true);
playSound.start();
};
this.elmMain.elmVolume.onPress = function ()
{
startDrag (this, false, 174, 137, 273, 137);
};
this.elmMain.elmVolume.onRelease = function ()
{
stopDrag ();
};
this.vol = function ()
{
this.volumeControl = elmVolume._x - 174;
playSound.setVolume(this.volumeControl);
};
} // End of the function
var objPlayer = new player(this);
}
onClipEvent (enterFrame)
{
objPlayer.vol();
objPlayer.duracao();
}
Me ajudem aí.
Carregando comentários...