Valeu Jonas!!
Eu uso o XML somente pra tranferencia... hehehe Da uma olhada nos códigos
abaixo!
O m3u é composto por:
#EXTM3U
#EXTINF:301,TRUSTCOMPANY . DEEPER INTO YOU
http://www.des16n.com.br/teste/TRUSTcompany - Deeper Into You.mp3
#EXTINF:302,TRUSTCOMPANY . DROP TO ZERO
http://www.indaiaonline.com.br/des16n_player/TRUSTcompany - Drop to zero.mp3
#EXTINF:303,TRUSTCOMPANY . FALLING APART
http://www.indaiaonline.com.br/des16n_player/TRUSTcompany - Falling
apart.mp3
A.S "caminho do M3U".:
function M3UPpc()
{
this.playLista = [];
}
M3UPpc.prototype.load = function(arquivo)
{
this.m3u = new XML();
this.retornoAlvo = returnoAlvo;
this.m3u.controle = this;
this.m3u.onLoad = function(sucesso)
{
if(sucesso)
this.controle.comecaranaliseM3U(this);
else
this.controle.onLoad(false);
}
this.m3u.load(arquivo);
}
M3UPpc.prototype.comecaranaliseM3U = function(m3u)
{
delete m3u.onLoad;
delete m3u.controle;
var stm = unescape(m3u.toString());
var _tituloEncontrado = 2;
var _caminhoEncontrado = 3;
var estado = null;
var playListaRS = [];
var linhaComeco = stm.indexOf("\n", stm.indexOf("#EXTM3U", 0)) + 1;
var linhaFim = linhaComeco;
var linhaContagem = 0;
var linhaCorrente = "";
var tituloCarregar = [];
while(linhaFim != -1)
{
linnhaComeco = (linhaContagem == 0) ? 0 : linhaFim + 1;
linhaFim = stm.indexOf("\n", linhaFim + 1);
linhaCorrente = stm.substring(linhaComeco, linhaFim - 1);
linhaContagem ++;
var tituloObtido = (linhaCorrente.indexOf("#EXTINF", 0) != -1);
if(tituloObtido)
{
var titulo = linhaCorrente.substring(linhaCorrente.indexOf(",", 0) + 1,
linhaCorrente.length);
tituloCarregar.push(titulo);
estado = _tituloEncontrado;
} else {
if(linhaCorrente.length > 1)
{ var caminho = linhaCorrente;
var titulo = (tituloCarregar.length > 0) ? tituloCarregar.pop() :
caminho;
playListaRS.push({tempo:segundos, titulo:titulo, caminho:caminho});
estado = _caminhoEncontrado;
}
}
}
this.playLista = playListaRS;
this.onLoad(true);
}
AS.: tchan tchan tchan tchannnnn "Função de stream":
Number.numerosrandomicos = function (baixa, alta, cont) {
var numerosran = new Array();
var nums = new Array();
for (var i = baixa; i<=alta; ++i) {
nums.push(i);
}
for (var i = 0; i<=count; ++i) {
var numerorandomico = Math.floor(Math.random()*nums.length);
numerosran.push(nums[numerorandomico]);
nums.splice(numerorandomico, 1);
}
return numerosran;
};
function iniciar(Lista)
{
setInterval(statusUpdate, 100);
this.m3up = new M3UPpc();
this.m3up.controle = this;
this.m3up.onLoad = function(sucesso) {
this.controle.receberPlayLista(this.playlista); }
this.m3up.load(Lista);
cont=0;
}
function receberPlayLista(playLista)
{
listbox.removeAll();
for(var i = 0; i < playlista.length; i++)
{
if((playLista[i].titulo.indexOf("'")!= -1)||(playLista[i].caminho.index
Of("'")!= -1))
{
tempTitulo = playLista[i].titulo.split("'");
playLista[i].titulo = tempTitulo.join("'");
tempCaminho = playLista[i].caminho.split("'");
playLista[i].caminho = tempCaminho.join("'");
}
if((playLista[i].titulo.indexOf(""")!= -1)||(playLista[i].caminho.index
Of(""")!= -1))
{
tempTitulo = playLista[i].titulo.split(""");
playLista[i].titulo = tempTitulo.join("\"");
tempCaminho = playLista[i].caminho.split(""");
playLista[i].caminho = tempCaminho.join("\"");
}
if((playLista[i].titulo.indexOf("&")!= -1)||(playLista[i].caminho.indexO
f("&")!= -1))
{
tempTitulo = playLista[i].titulo.split("&");
playLista[i].titulo = tempTitulo.join("&");
tempCaminho = playLista[i].caminho.split("&");
playLista[i].caminho = tempCaminho.join("&");
}
listBox.addItem(playLista[i].titulo, playLista[i].caminho);
}
listBox.sortItemsBy("label", "ASC");
musicaRandomicaArray=Number.numerosran(0,playlista.length-1,playlista.length
-1)
total= playlista.length
}
function criarPlayLista(playLista)
{
listbox.removeAll();
for (var i = 0; i < playlista.length; i++) {
listBox.addItem(playLista[i][0], playLista[i][1]);
}
}
function mudarVolume()
{
objetoSom.setVolume(_root.volume);
}
function playMusica(componente)
{
var fileCaminho = Componente.getSelectedItem().data;
ObjetoSom.stop();
delete ObjetoSom;
ObjetoSom = new Sound(this);
ObjetoSom.loadSound(fileCaminho, true);
ObjetoSom.onSoundComplete = playProxima;
pausaPosicao=0;
}
function startMusica()
{
indicador.gotoAndStop(2);
musicaPausada=false;
mudarVolume();
ObjetoSom.start();
}
function playAnt()
{
if(shuffleMusicas)
{
if(cont>0)
{
var nextIndex= Number(musicaRandomicaArray[cont-1]);
cont--;
}
else
{
var nextIndex= Number(musicaRandomicaArray[total]);
cont=total;
}
listbox.setScrollPosition(nextIndex)
}
else
{
var nextIndex = listbox.getSelectedIndex() - 1;
if (nextIndex < 0) {
nextIndex = listbox.getLength() - 1;
}
}
pausePosicao=0;
indicador.gotoAndStop(2);
listbox.setSelectedIndex(nextIndex);
}
function playNext()
{
if(shuffleMusicas)
{
if(cont<total-1)
{
var nextIndex= Number(musicaRandomicaArray[cont+1]);
cont++;
}
else
{
var nextIndex= Number(musicaRandomicaArray[0]);
cont=0;
}
listbox.setScrollPosition(nextIndex)
}
else
{
var nextIndex = listbox.getSelectedIndex() + 1;
if (nextIndex >= listbox.getLength()) {
nextIndex = 0;
}
}
pausePosicao=0;
indicador.gotoAndStop(2);
listbox.setSelectedIndex(nextIndex);
}
function stopMusica()
{
indicador.gotoAndStop(1);
listbox.setSelectedIndex(null);
objetoSom.position=0;
pausePosicao=0;
objetoSom.stop();
}
function rewindMusica()
{
songPausada=false;
correntePos= soundObject.position;
correntePos -=1000;
ObjetoSom.stop();
ObjetoSom.start(correntePos/1000);
indicador.gotoAndStop(2);
}
function forwardMusica()
{
songPausada=false;
correntePos= soundObject.position;
correntePos +=1000;
objetoSom.stop();
objetoSom.start(correntePos/1000);
indicador.gotoAndStop(2);
}
function statusUpdate()
{
if(listbox.getSelectedItem().label !=null)
{
var elaspedseconds = Math.floor(objetoSom.position / 1000);
var minutos = Math.floor(elaspedseconds / 60);
var segundos = elaspedseconds - minutos * 60;
if (minutos < 10) {
minutos = "0" + minutos;
}
if (segundos < 10) {
segundos = "0" + segundos;
}
var totalsegundos = Math.floor(objetoSom.duration / 1000);
var totalmins = Math.floor(totalsegundos / 60);
var totalsegs = totalsegundos - totalmins * 60;
if (totalmins < 10) {
totalmins = "0" + totalmins;
}
if (totalsegs < 10) {
totalsegs = "0" + totalsegs;
}
tempo = minutos add ":" add segundos add " / " add totalmins add ":" add
totalsegs;
track_playing = listbox.getSelectedItem().label;
percent= objetoSom.getBytesLoaded()/objetoSom.getBytesTotal();
percent_loaded= Math.floor(percent*100) add "%"
}
else
{
time= "00:00 / 00:00";
track_playing= "SELECIONE E CURTA";
}
}
init("lista.m3u");
Sei que entendeu! hehehe
Grande Abraço e to esperando o seu Livro!! E por falar nisso... ce pensou no
projeto OMO (onMouseOver)?
[]'s
..:: Dauton Janota
..:: dauton.janota@...
..:: dj@...
..:: www.des16n.com.br
..:: 138086170 - immer angeschloßen !
> Legal Dauton!
>
> Eu nunca pensei na possibilidade de carregar listas M3U no Flash para
obter
> as urls, é bem interessante. Mas um fato me deixou curioso: abri um
arquivo
> M3U em um editor de texto e notei que o formato não é XML. Você manipulou
a
> string conteúdo raw do arquivo? Utilizando o onData?
>
> Um abraço.
> // Jonas Galvez
> // Consultor Macromedia Brasil
> // Macromedia Authorized Brazilian Speaker
>