Comunidad de diseño web y desarrollo en internet online

Atascado con Streaming en reproductor de audio xml

Citar            
MensajeEscrito el 02 Sep 2008 02:13 pm
Hola a todos!!

Estoy intentando modificar un reproductor de audio que tenia en flash y que carga los archivos .mp3 desde un .xml para que los cargue en streaming, pero ya llevo algún tiempo con esto y no avanzo.. :wtf:
Alguien puede orientarme un poco?

Código :

//Mp3 Player with playlist 
//Written by John Bezanis for SWF Spot. http://www.swfspot.com
stop();
var songs:Array = new Array();
var curtrack:Number = 0;
var playingsong:Sound = new Sound();
if (_root.playlist == undefined || _root.playlist == "") {
   _root.playlist = "artistas/psicorama/traks/playlist.xml";
}
var playlistXml:XML = new XML();
playlistXml.ignoreWhite = true;
playlistXml.load(_root.playlist);
playlistXml.onLoad = function() {
   loadSongs();
   loadplaylistbox();
   loadSong(curtrack);
   if (_root.autostart == "false") {
      toggleplaypause();
   }
};
function loadSongs() {
   for (songIndex=0; songIndex<playlistXml.childNodes[0].childNodes[0].childNodes.length; songIndex++) {
      var songdata:Object = new Object();
      for (songNode=0; songNode<playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes.length; songNode++) {
         switch (playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].nodeName) {
            case "creator" :
               songdata.artist = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
               break;
            case "title" :
               songdata.title = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
               break;
            case "location" :
               songdata.location = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
               break;
         }
      }
      songs[songIndex] = songdata;
   }
}
function loadSong(track) {
   playingsong = new Sound();
   playingsong.loadSound(songs[track].location,false);
   playingsong.start(0);
   updatevolume();
   playingsong.onSoundComplete = function() {
      loadSong((curtrack+1)%(songs.length));
   };
   playpause.gotoAndStop(2);
   playpause.playpausebutton.onPress = function() {
      toggleplaypause();
   };
   songdisplay.text = songs[track].artist+" - "+songs[track].title;
   eval("playlistbox.playlistitemcontainer.playlistitem"+curtrack+".playlistitemhighlight")._alpha = 4;
   eval("playlistbox.playlistitemcontainer.playlistitem"+track+".playlistitemhighlight")._alpha = 20;
   curtrack = track;
}
function loadplaylistbox() {
   for (songIndex=0; songIndex<playlistXml.childNodes[0].childNodes[0].childNodes.length; songIndex++) {
      playlistbox.playlistitemcontainer.attachMovie("playlistitem","playlistitem"+songIndex,playlistbox.playlistitemcontainer.getNextHighestDepth(),{_x:0, _y:15*songIndex});
      eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".playlistitemtext").text = songs[songIndex].artist+" - "+songs[songIndex].title;
      eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex).songindex = songIndex;
   }
}
playpause.playpausebutton.onPress = function() {
   toggleplaypause();
};
function toggleplaypause() {
   if (playpause._currentframe == 1) {
      playpause.gotoAndStop(2);
      playpause.curpos = playingsong.position;
      playingsong.stop();
   } else {
      playpause.gotoAndStop(1);
      playingsong.start(playpause.curpos/1000,0);
   }
   playpause.playpausebutton.onPress = function() {
      toggleplaypause();
   };
}
onEnterFrame = function () {
   if (songdisplay.movingright) {
      songdisplay.hscroll -= 10;
      if (songdisplay.hscroll<=0) {
         songdisplay.movingright = false;
      }
   } else {
      songdisplay.hscroll += 10;
      if (songdisplay.hscroll>=songdisplay.maxhscroll) {
         songdisplay.movingright = true;
      }
   }
   if (!draggingslider) {
      progressslider._x = (playingsong.position/playingsong.duration)*182+61;
      if (progressslider._x == 0) {
         progressslider._x = 61;
      }
   }
   if (draggingplaylistscroller) {
      updateplaylistscroll();
   }
   if (draggingvolmeslider) {
      updatevolume();
   }
   tempsongtime = "";
   if (Math.floor(playingsong.position/60000) == 0) {
      tempsongtime += "0";
   } else {
      tempsongtime += Math.floor(playingsong.position/60000);
   }
   tempsongtime += ":";
   if (Math.floor((playingsong.position/1000)%60)<10) {
      tempsongtime += "0";
   }
   tempsongtime += Math.floor((playingsong.position/1000)%60);
   tempsongtime += "/";
   if (Math.floor(playingsong.duration/60000) == 0) {
      tempsongtime += "0";
   } else {
      tempsongtime += Math.floor(playingsong.duration/60000);
   }
   tempsongtime += ":";
   if (Math.floor((playingsong.duration/1000)%60)<10) {
      tempsongtime += "0";
   }
   tempsongtime += Math.floor((playingsong.duration/1000)%60);
   this.progressslider.songtime.text = tempsongtime;
   //trace(Math.floor(playingsong.position/60000));
   //if(Math.floor(playingsong.position/1000)%60)
   //songtime.text=Math.floor(playingsong.position/1000)%60+"/"+Math.floor(playingsong.duration/1000)%60;
};

volumebar.onPress = function() {
   draggingvolmeslider = true;
   volumebar.volumeslider.startDrag(true,0,volumebar.volumeslider._y,47,volumebar.volumeslider._y);
};
volumebar.onRelease = volumebar.onReleaseOutside=function () {
   draggingvolmeslider = false;
   volumebar.volumeslider.stopDrag();
   updatevolume();
};
function updatevolume() {
   playingsong.setVolume((volumebar.volumeslider._x/47)*100);
}
previoussong.onPress = function() {
   loadprevioussong();
};
function loadprevioussong() {
   var loadtrack = (curtrack-1)%(songs.length);
   if (loadtrack<0) {
      loadtrack = songs.length-1;
   }
   loadSong(loadtrack);
}
nextsong.onPress = function() {
   loadnextsong();
};
function loadnextsong() {
   var loadtrack = (curtrack+1)%(songs.length);
   loadSong(loadtrack);
}
playlistscroller.onPress = function() {
   draggingplaylistscroller = true;
   playlistscroller.startDrag(true,283,70,283,171);
};
playlistscroller.onRelease = playlistscroller.onReleaseOutside=function () {
   draggingplaylistscroller = false;
   playlistscroller.stopDrag();
};
playlistscrollup.onPress = function() {
   playlistscroller._y = Math.max(70, playlistscroller._y-10);
   updateplaylistscroll();
};
playlistscrolldown.onPress = function() {
   playlistscroller._y = Math.min(171, playlistscroller._y+10);
   updateplaylistscroll();
};
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta:Number) {
   playlistscroller._y = Math.min(171, Math.max(70, playlistscroller._y-delta));
   updateplaylistscroll();
};
Mouse.addListener(mouseListener);
playlistscrollbar.onPress = function() {
   playlistscroller._y = Math.min(171, Math.max(70, _ymouse));
   updateplaylistscroll();
};
function updateplaylistscroll() {
   playlistbox.playlistitemcontainer._y = -((playlistscroller._y-70)/101)*(playlistbox.playlistitemcontainer._height-149);
}
function visitswfspot() {
   getURL("http://www.swfspot.com", "_blank");
}
var myMenu = new ContextMenu();
var menubezz = new ContextMenuItem("SWF Spot Mp3 Player", visitswfspot);
myMenu.customItems.push(menubezz);
var menuplaypause = new ContextMenuItem("Play / Pause", toggleplaypause);
menuplaypause.separatorBefore = true;
myMenu.customItems.push(menuplaypause);
var menuprevioustrack = new ContextMenuItem("Previous Song", loadprevioussong);
myMenu.customItems.push(menuprevioustrack);
var menunexttrack = new ContextMenuItem("Next Song", loadnextsong);
myMenu.customItems.push(menunexttrack);
myMenu.hideBuiltInItems();
_root.menu = myMenu;


Saludos!

Por Fusel

Claber

339 de clabLevel



Genero:Masculino  

Madrid (España)

safari
Citar            
MensajeEscrito el 02 Sep 2008 03:29 pm
200 líneas de código, muy interesante
¿Cual sería la pregunta?

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 02 Sep 2008 04:08 pm
Quiero cargar las pistas en streaming, tal y como está, hasta que no carga por completo el tema no lo reproduce.

Por Fusel

Claber

339 de clabLevel



Genero:Masculino  

Madrid (España)

safari
Citar            
MensajeEscrito el 02 Sep 2008 04:27 pm
Cambia esta línea:

playingsong.loadSound(songs[track].location,false);

a

playingsong.loadSound(songs[track].location,true);

Y si ves otro loadSound por ahí, el segundo argumento siempre a true

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 03 Sep 2008 08:23 am
Muchisimas gracias!! :wink: (y)
Funciona perfecto, pero ahora me hace una cosa rara que antes no me hacia, la barrita de progreso (progressslider) se vuelve loca :wtf: :wtf:

Por Fusel

Claber

339 de clabLevel



Genero:Masculino  

Madrid (España)

safari
Citar            
MensajeEscrito el 03 Sep 2008 09:29 am
Alguno de estos dos datos no están definidos:

playingsong.position o playingsong.duration

Trázalos a ver que valores salen, en todo caso puedes ebitar que se actualice si alguno es undefined

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 03 Sep 2008 09:55 am
Rresuelto!! :D
Mil gracias solisarg!! En unos días estará terminado el proyecto!!

Por Fusel

Claber

339 de clabLevel



Genero:Masculino  

Madrid (España)

safari
Citar            
MensajeEscrito el 03 Sep 2008 09:49 pm
Ahora me surge otro problemilla :meditar: , estoy usando varios reproductores que se cargan en un mc vacio, el primero carga ok, pero cuando le digo que cargue otro en ese mismo mc no lo hace, es como si se cargara el mismo de nuevo.
Estoy buscando información por el foro pero no encuentro nada.

Por Fusel

Claber

339 de clabLevel



Genero:Masculino  

Madrid (España)

safari
Citar            
MensajeEscrito el 03 Sep 2008 10:01 pm
El playlist lo está pillando de una variable en _root

playlistXml.load(_root.playlist);

Si esa variable no cambia, es probable que cargue siempre el mismo XML, a menos que uses _lockroot = true al principio del reproductor

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 04 Sep 2008 08:12 am
:alabado: :alabado: :alabado: :alabado:
Mil gracias de nuevo solisarg!!

Por Fusel

Claber

339 de clabLevel



Genero:Masculino  

Madrid (España)

safari

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.