Comunidad de diseño web y desarrollo en internet online

Reproductor de Mp3

Citar            
MensajeEscrito el 10 Ene 2008 06:09 pm
Hola, estoy poniendo musica a un sitio. Para esto tuve que armar un frame para el reproductor del mp3, ya que la pagina originalmente hacia refresh cada vez que se presionaba el boton.

El problema que se me presenta es que cada vez que presiono el boton Home, se crean 2 instancias del reproductor. es decir que quedan 2 canciones reproduciendose pero en distintas partes del tema. :crap:

Se me ocurrio ponerle un control al flash que diga que si se esta reproduciendo, no lo vuelva a cargar.
Si me podrian guiar o decirme donde puedo encontrar la solcuion se los agradeceria!
^^

Por rommat

2 de clabLevel



Genero:Femenino  

msie
Citar            
MensajeEscrito el 10 Ene 2008 06:18 pm
cargaste asi tu sonido ?

Código :

// crea un objeto Sound nuevo
var my_sound:Sound = new Sound();
// si se carga el sonido, reproducirlo; si no, rastrear la carga del fallo
my_sound.onLoad = function(success:Boolean) {
if (success) {
my_sound.start();

} else {
   trace("no funciona")
}
};
// carga el sonido
my_sound.loadSound("musica.mp3", true);


sino lo tienes hazlo asi , se supone que no te deberia dar problemas, sino funciona vienes.

Por DiegoAzul

376 de clabLevel



 

Mx

firefox
Citar            
MensajeEscrito el 10 Ene 2008 06:43 pm
Te pego el codigo que estoy usando para el reproductor. creo que deberia pornerle un if en donde pregunta por el success del xml... las canciones se cargan en una lista xml y las reproduce flash.


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

//create a variable to hold the Sound object
var MP3ToPlay:Sound = new Sound();

//create a variable to hold the number of the song that is playing
var songNum:Number = 0;

//creates an array that holds the entire list of songs contained in the XML file
var songs_lst:Array = new Array();

//function to load the XML file that contains the Songs
//"success" is passed into this function to determine if and when the Function executes
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"
_root.numberOfSongs = FolderNode.childNodes.length;

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

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

//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(){
_root.songNum = _root.songNum + 1;
if(_root.songNum == (_root.numberOfSongs)){ _root.songNum = 0; }
field.songName.text = "Song Buffering";
_root.accessSongs();
}

//makes sure that the sound file does not play until it is loaded completely
if((MP3ToPlay.getBytesLoaded() == MP3ToPlay.getBytesTotal()) && MP3ToPlay.duration > 0){
field.songName.text = "";
field.songName.text += MP3ToPlay.id3.songname;
}
}

}

MP3ToPlay.loadSound(SelectedSong, false);

}

stop();

Por rommat

2 de clabLevel



Genero:Femenino  

msie

 

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