Como dar um Auto-Play no MP3 Player?
Eu peguei um exemplo de player e está perfeito!
Ele pega as músicas por xml, mas não sei como criar uma função de auto-player ao entrar no frame.
Segue o ActionScript:
function parser()
{
var _loc3 = xml.firstChild;
var _loc4 = _loc3.childNodes.length;
for (var _loc2 = 0; _loc2 < _loc4; ++_loc2)
{
var _loc1 = new Object();
_loc1.nome = _loc3.childNodes[_loc2].childNodes[0].firstChild.nodeValue;
_loc1.link = _loc3.childNodes[_loc2].childNodes[1].firstChild.nodeValue;
_loc1.superID = _loc2;
arrMus.push(_loc1);
false;
trace (_loc1.nome);
} // end of for
false;
false;
som.loadSound(musUrl + arrMus[idAtual].link, false);
display_mc.rotulo_txt.text = arrMus[idAtual].nome;
play_mc.gotoAndStop(2);
play_mc.enabled = true;} // End of the function
function trocarMusica(modo)
{
som.stop();
var _loc1 = idAtual;
if (modo == "avancar")
{
if (_loc1 < arrMus.length - 1)
{
++_loc1;
}
else
{
_loc1 = 0;
} // end else if
}
else if (modo == "voltar")
{
if (_loc1 > 0)
{
--_loc1;
}
else if (_loc1 <= 0)
{
_loc1 = arrMus.length - 1;
} // end else if
} // end else if
idAtual = _loc1;
som.loadSound(musUrl + arrMus[_loc1].link, true);
display_mc.rotulo_txt.text = arrMus[idAtual].nome;
play_mc.gotoAndStop(2);
play_mc.enabled = false;
stop_mc.gotoAndStop(1);
stop_mc.enabled = true;
isPlaying = true;} // End of the function
stop ();
var xml = new XML();
var xmlUrl = new String();
var arrMus = new Array();
var musUrl = new String();
var arrBts = new Array();
var idAtual = 0;
var isPlaying = true;
_global.regional = _level0.reg;
var som = new Sound();if (_level0._url.substr(0, 4) == "http")
{
xmlUrl = "/musicaslista.xml";
musUrl = "/musicas/";
}else
{
musUrl = "";
xmlUrl = "musicaslista.xml";} // end else if
xml.ignoreWhite = xml2.ignoreWhite = true;
xml.onLoad = function (s){
s ? (parser()) : (trace ("xml poli falhou"));
};
xml.load(xmlUrl);
setProperty("", _soundbuftime, 5);
som.onSoundComplete = function (){
trocarMusica("avancar");
};
this.stop_mc.onRelease = function (){
play_mc.gotoAndStop(1);
play_mc.enabled = true;
this.gotoAndStop(2);
this.enabled = false;
play_mc.enabled = true;
som.stop();
isPlaying = false;
};
this.play_mc.onRelease = function (){
this.gotoAndStop(2);
this.enabled = false;
stop_mc.gotoAndStop(1);
stop_mc.enabled = true;
som.start();
isPlaying = true;
};
this.proxima_mc.onRelease = function (){
this.gotoAndStop(2);
stop_mc.gotoAndStop(1);
trocarMusica("avancar");
};
this.anterior_mc.onRelease = function (){
this.gotoAndStop(2);
stop_mc.gotoAndStop(1);
trocarMusica("voltar");
};
this.stop_mc.onRollOver = this.play_mc.onRollOver = function (){
this.gotoAndStop(2);
};
this.stop_mc.onRollOut = function (){
isPlaying ? (this.gotoAndStop(1)) : (this.gotoAndStop(2));
};
this.play_mc.onRollOut = function (){
isPlaying ? (this.gotoAndStop(2)) : (this.gotoAndStop(1));
};Reparem que o que eu quero que ele faça automaticamente é isso:
this.play_mc.onRelease = function ()
{
this.gotoAndStop(2);
this.enabled = false;
stop_mc.gotoAndStop(1);
stop_mc.enabled = true;
som.start();
isPlaying = true;
};Já tentei com onEnterFrame, mas a musica começa a carregar várias e várias vezes ela por cima dela mesma (parece um grande eco sem fim).
Pois onEnterFrame não é uma boa idéia :rolleyes:
QUEM PUDER AJUDAR, AGRADEÇO MUITO! Muito! http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif
Boa tarde a todos! E bom final de semana!
Discussão (1)
Carregando comentários...