Foros del Web » Creando para Internet » Flash y Actionscript »

MP3 Player no avanza automatico

Estas en el tema de MP3 Player no avanza automatico en el foro de Flash y Actionscript en Foros del Web. He tomado un MP3 player sencillo y de codigo abierto y lo he modificado para que funcione en la pagina que estoy haciendo, para empezar ...
  #1 (permalink)  
Antiguo 22/02/2008, 08:41
 
Fecha de Ingreso: febrero-2007
Mensajes: 10
Antigüedad: 10 años, 10 meses
Puntos: 0
MP3 Player no avanza automatico

He tomado un MP3 player sencillo y de codigo abierto y lo he modificado para que funcione en la pagina que estoy haciendo, para empezar no se nada de ActionScript pero averiguando en la web con algunas guias lo he aclopado a mi flash pero no logro hacer que avance automaticamente a la otra cancion (esto si lo hace originalmente), no se si sea porque lo estoy llamando desde otro flash.

Aqui el codigo:

//generic actions involoved in loading XML and stripping whitespace
var SongsXML:XML = new XML();
SongsXML.ignoreWhite = true;
SongsXML.onLoad = loadSongsXML;
SongsXML.load("swf/mySongs.xml");

//creando la variable que esperara el Sound object
var MP3ToPlay:Sound = new Sound();

//creando la variale que esperara el numero de cancion a ser tocada
var songNum:Number = 0;

//creando el arreglo que esperara la lista entera de canciones que contiene XML file
var songs_lst:Array = new Array();

//funcion que llama el XML file que contiene las canciones
//"success" es pasado dentro de esta funcion para determinar si y cuando la funcion se ejecuta


function loadSongsXML(success):Void {

//if "success" gets passed here, that means the loadSongsXML function executed, so the following code will execute
if (success) { accessSongs(); }

}


function accessSongs(){

//set FolderNode variable equal to first ChildNode
//What the f does this mean? Well, it is setting up a variable called FolderNode, to hold the XML Node
//called "Folder," (in this case, the artist name)
//it is then locating this object in the XML document and setting it as the value of this variable
var FolderNode:XMLNode = SongsXML.firstChild.childNodes[0];


//Cycle through FolderNode, and add each item to songs_lst variable
//songs_lst was initialized above as an array. This for statement populates that array
for (var j:Number = 0 ; j < FolderNode.childNodes.length ; j++) {
songs_lst.addItem(FolderNode.childNodes[j].attributes.file);
}

//set the variable "currentSong" equal to the Childnode of "FolderNode" that is in the
//position referred to by the variable "songNum" (which is initialized above)
currentSong = FolderNode.childNodes[songNum].attributes.file;

//sets the Var numberOfSongs equal to the number (length) of childnodes within "FolderNode"
this.numberOfSongs = FolderNode.childNodes.length;

//initialize variable that holds selected song
//and concatenate the path the that file using variables created above
SelectedSong = "musica/" + currentSong;

//stop sounds because we are going to load a new one in a minute
stopAllSounds();
//set the initial volume
var startVolume:Number=80;

//this function checks that MP3ToPlay loads successfully
MP3ToPlay.onLoad = function(success:Boolean) {

//if sound loaded successfully, then set the volume and start playing the sound
if (success) {
MP3ToPlay.setVolume(startVolume);
MP3ToPlay.start();

//once the current sound finishes playing, perform this action
//which advances the playlist to the next song
MP3ToPlay.onSoundComplete = function(){
this.songNum = this.songNum + 1;
if(this.songNum == (this.numberOfSongs)){ this.songNum = 0; }
field.songName.text = "";
field.songName.text = "Song Buffering";
this.accessSongs();
}

}

}

//loads a sounds into the var MP3ToPlay that was created above.
//The song is loaded from the string created above in "selected song"
//The "false" refers to the streaming parameter
MP3ToPlay.loadSound(SelectedSong, true);
field.onEnterFrame = function() {
BytesLoaded = MP3ToPlay.getBytesLoaded();
BytesTotal = MP3ToPlay.getBytesTotal();
porcentaje = Math.floor(BytesLoaded/BytesTotal*100);
if (!isNaN(porcentaje)) {
field.estado.text = porcentaje+"% cargado";
field.songName.text = "";
field.songName.text += MP3ToPlay.id3.songname;
field.songAlbum.text = "";
field.songAlbum.text += MP3ToPlay.id3.album;
field.songArtist.text = "";
field.songArtist.text += MP3ToPlay.id3.artist;}
};
MP3ToPlay.onLoad = function() {
delete field.onEnterFrame;
field.estado.text = "carga completa";};
}

stop();
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:54.