CNT Renato 0 Denunciar post Postado Setembro 17, 2009 Bom... Consegui finalmente montar um MP3 player utilizando XML, porém tem um problema... local funciona que é uma maravilha, mas quando jogo no servidor, onde estaria os nomes das musicas fica como "undefined" isso seria porque ele não está conseguindo ler o XML ? Agradeço a atenção import mx.transitions.Tween; import mx.transitions.easing.*; var musicas:String = "musicas/"; var lista:Array = new Array(); var lista_musica:Array = new Array(); var lista_artista:Array = new Array(); var lista_album:Array = new Array(); var current:Number = 0; var position:Number; var new_volume:Number = 100; var musicas_xml:XML = new XML(); musicas_xml.ignoreWhite = true; musicas_xml.onLoad = function() { var nodes:Array = this.firstChild.childNodes; for(var i = 0; i < nodes.length; i++) { lista.push(musicas + nodes[i].attributes.arq); lista_musica.push(nodes[i].attributes.nome ); lista_artista.push(nodes[i].attributes.artista); lista_album.push(nodes[i].attributes.album); } play_song("start"); } musicas_xml.load("musicas.xml"); btn_play.play_pause.onRelease = function() { if( this._parent._currentframe == 1 ) this._parent._parent.play_pause("pause"); else this._parent._parent.play_pause("play"); this._parent.play(); } btn_ant.onRelease = function() { this._parent.play_song("prev"); } btn_prox.onRelease = function() { this._parent.play_song("next"); } function play_song(faixa:String):Void { if(faixa == "prev") current--; else if(faixa == "start") current = 0; else current++; if(current == lista.length) current = 0; else if(current < 0) current = lista.length - 1; s = new Sound(); s.loadSound(lista[current], true); s.setVolume(new_volume); cnt_musica.text = lista_musica[current]; cnt_artista.text = lista_artista[current]; cnt_album.text = lista_album[current]; btn_play.gotoAndStop(1); } function play_pause(pp:String):Void { if(pp == "pause") { position = s.position; s.stop(); } else if(pp == "play") { s.start(position/1000); } } var my_interval:Number; my_interval = setInterval(update_bar, 100); function update_bar():Void { var total_seconds:Number = s.duration/1000; var minutes:Number = Math.floor(total_seconds/60); var seconds = Math.floor(total_seconds)%60; if(seconds < 10) seconds = "0" + seconds; var total_current_seconds:Number = s.position/1000; var current_minutes:Number = Math.floor(total_current_seconds/60); var current_seconds = Math.floor(total_current_seconds)%60; if(current_seconds < 10) current_seconds = "0" + current_seconds; percent_loaded = Math.round(s.getBytesLoaded() / s.getBytesTotal() * 100); if( percent_loaded != 100 && percent_loaded > 0) carregar.text = "Carregando... " + percent_loaded + "%"; else carregar.text = ""; barra._width = Math.round( s.position/s.duration*barra_bg._width ); indicador._x = barra._width + barra._x; tempo.text = current_minutes +":"+ current_seconds + " / " + minutes +":"+ seconds; if( s.getBytesLoaded() == s.getBytesTotal() && s.position == s.duration ) play_song(); } var theMenu:ContextMenu = new ContextMenu(); theMenu.hideBuiltInItems(); _root.menu = theMenu; var item:ContextMenuItem = new ContextMenuItem("Created by CNT Mídia", CNT); theMenu.customItems[0] = item; function CNT() { getURL("http://www.cntmidia.com.br"); } indicador.onPress = function() { this.startDrag(true, barra_bg._x, this._y, barra_bg._width + barra_bg._x, this._y ); s.stop(); clearInterval(my_interval); } indicador.onRelease = indicador.onReleaseOutside = function() { this.stopDrag(); new_position = s.duration * (this._x - barra_bg._x) / (barra_bg._width * 1000); s.start(new_position); btn_play.gotoAndStop(1); my_interval = setInterval(update_bar, 100); } volume_pointer.onPress = function() { this.startDrag(true,volume_bg._x,this._y,volume_bg._width+volume_bg._x,this._y); } volume_pointer.onRelease = volume_pointer.onReleaseOutside = function() { this.stopDrag(); new_volume = this._x - volume_bg._x; new Tween(volume, "_width", Strong.easeOut, volume._width, new_volume, 1.5, true); s.setVolume(new_volume); } site: www.grupoftm.com.br Compartilhar este post Link para o post Compartilhar em outros sites
Thiago de Oliveira Cruz 21 Denunciar post Postado Setembro 17, 2009 Coloque o caminho completo até a pasta http://www.seusite.com/mp3/musica.mp3 Por exemplo no seu XML Caminhos relativos e flash não combinam Abraços Compartilhar este post Link para o post Compartilhar em outros sites
CNT Renato 0 Denunciar post Postado Setembro 17, 2009 Bom... nas declarações: var musicas:String = "musicas/"; ... musicas_xml.load("musicas.xml"); coloquei assim: var musicas:String = "http://grupoftm.com.br/musicas/"; ... musicas_xml.load("http://grupoftm.com.br/musicas.xml"); Ele até leu o XML, mas de qqer forma não executa nem carrega os arquivos. Alguma outra idéia ? Compartilhar este post Link para o post Compartilhar em outros sites
Thiago de Oliveira Cruz 21 Denunciar post Postado Setembro 18, 2009 Como está seu xml? abraços Compartilhar este post Link para o post Compartilhar em outros sites