Comunidad de diseño web y desarrollo en internet online

Error Sound con Safari

Citar            
MensajeEscrito el 15 Abr 2009 08:34 pm
Hola a todos,
Situación: Tengo una página web con un reproductor de audio con un tema que se reproduce al cargar (exigencias del cliente...).
En la misma página hay otro reproductor que reproduce el mismo audio pero que al cargar no se reproduce. (¿?¿?¿? también exigencias del cliente...)
El problema: Localmente funciona, pero al publicarlo en la web los dos reproductores reproducen el audio al entrar en la web. Pero... solo en SAFARI!!
Podría ser un problema con onLoad ??

He útilizado el objeto sound, adjunto código de los dos archivos.
Si ven cualquier otro error o comentario sobre el código, me encantará oir su opinión.
Muchas gracias a todos!

Primer swf (se reproduce al inicio):

Código :

var pausa:Number = 0;
var estado:Number = 1;

btn.gotoAndStop(2);
var my_interval:Number;
var my_sound:Sound = new Sound();

my_sound.onLoad = function(success:Boolean) {
    if (success) {
         my_interval = setInterval(updateProgressBar, 100, my_sound);
    }
};

my_sound.onSoundComplete = function() {
   clearInterval(my_interval);
}
   
my_sound.loadSound("http://www.miweb.com/media/audio.mp3", true);

function updateProgressBar(the_sound:Sound):Void {
    var pos:Number = Math.round(the_sound.position/the_sound.duration*116);
   progressBar_mc.barra._x = pos;
}

btn.onRelease = function (){
      if(estado == 0){
         my_sound.start(pausa/1000);
         estado = 1;
         this.gotoAndStop(2);   
         mut_mc.gotoAndStop(1);
         mut_mc.enabled = true;
            if(pausa == 0){
               my_interval = setInterval(updateProgressBar, 1000, my_sound);
            }
      } else {
         my_sound.stop();
         estado = 0;
         this.gotoAndStop(1);
         pausa = my_sound.position;
         mut_mc.enabled = false;
      }
}

mut_mc.onRelease = function(){
   
   if( estado == 1){
      my_sound.stop();
      pos = 0;
      pausa = 0;
      estado = 0;
      clearInterval(my_interval);
      btn.gotoAndStop(1);
      this.gotoAndStop(2);
   
   }else{
      this.gotoAndStop(1);   
   }
}


Segundo swf (stop):

Código :

var pausa:Number = 0;
var estado2:Number = 0;

mut_mc.enabled = false;
var my_interval:Number;
var my_sound:Sound = new Sound();

my_sound.onLoad = function(success:Boolean) {
    if (success) {
         my_sound.stop();
    }
};

my_sound.onSoundComplete = function() {
   clearInterval(my_interval);
}
   
my_sound.loadSound("http://www.miweb.com/media/audio.mp3", true);

function updateProgressBar(the_sound:Sound):Void {
    var pos:Number = Math.round(the_sound.position/the_sound.duration*116);
   progressBar_mc.barra._x = pos;
}

btn.onRelease = function (){
      if(estado2 == 0){
         my_sound.start(pausa/1000);
         estado2 = 1;
         this.gotoAndStop(2);
         mut_mc.gotoAndStop(1);
         mut_mc.enabled = true;
            if(pausa == 0){
               my_interval = setInterval(updateProgressBar, 100, my_sound);
            }   
      } else {
         my_sound.stop();
         estado2 = 0;
         this.gotoAndStop(1);
         pausa = my_sound.position;
         mut_mc.enabled = false;
      }
}

mut_mc.onRelease = function(){
   
   if( estado2 == 1){
      my_sound.stop();
      pos = 0;
      pausa = 0;
      estado2 = 0;
      clearInterval(my_interval);
      btn.gotoAndStop(1);
      this.gotoAndStop(2);
   
   }else{
      this.gotoAndStop(1);   
   }
}

Por Elena Mon

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 16 Abr 2009 03:47 pm
Hola a todos,
por fin lo he solucionado.
Por si alguien le interesa este es el código AS2.
Por cierto, también añadí interación al "progressBar_mc.barra" controlando la posición del audio.
Espero que le sea útil a más gente!

[Nota: Utilizé swfObject]

Código :

var my_sound:Sound = new Sound();
var total:Number = 0;
var my_interval:Number;
var estado:Boolean = true;
var segmento:Number = 0;
var pausa:Number = 0;


/////////////////////////////
progressBar_mc.barra.enabled = false;
mut_mc.enabled = false;
/////////////////////////////

my_sound.onLoad = function(success:Boolean) {
   if(success){
         total = my_sound.duration/1000; // segundos liquidos
         segmento = 116/total;
   }
};

my_sound.onSoundComplete = function() {
   
   clearInterval(my_interval);
   progressBar_mc.barra._x = 0;
   btn.gotoAndStop(1);
   estado = true;
   pausa = 0;
};

my_sound.loadSound("http://www.miweb.com/media/audio.mp3", true);
my_sound.stop();


function updateProgressBar(the_sound:Sound):Void {
    var pos:Number = Math.round(the_sound.position/the_sound.duration*116);
   progressBar_mc.barra._x = pos;
}

//////////////////////////////

btn.onRelease = function (){
      if(estado == true){
         my_sound.start(pausa/1000);
         estado = false;
         this.gotoAndStop(2);
         mut_mc.gotoAndStop(1);
         mut_mc.enabled = true;
         progressBar_mc.barra.enabled = true;
         
            if(pausa == 0){
               my_interval = setInterval(updateProgressBar, 100, my_sound);
            }
            
      } else {
         my_sound.stop();
         estado = true;
         this.gotoAndStop(1);
         pausa = my_sound.position;
         mut_mc.enabled = false;
         progressBar_mc.barra.enabled = false;
      }
}

mut_mc.onRelease = function(){
   if(estado == false){
      my_sound.stop();
      progressBar_mc.barra._x = 0;
      my_sound.position = 0;
      pos = 0;
      pausa = 0;
      estado = true;
      clearInterval(my_interval);
      btn.gotoAndStop(1);
      this.gotoAndStop(2);
   
   }else{
      this.gotoAndStop(1);   
   }
}


//////////////////////////

progressBar_mc.barra.onPress = function () {
   this.startDrag(true,0,0,116,0);
   clearInterval(my_interval);
   stopAllSounds();
}

progressBar_mc.barra.onRelease = function () {
   this.stopDrag();
   pos_nuevo = progressBar_mc.barra._x/segmento; 
   my_sound.start(pos_nuevo,1);
   my_interval = setInterval(updateProgressBar, 100, my_sound);
}

progressBar_mc.barra.onReleaseOutside = function () {
   this.stopDrag();
   pos_nuevo =(progressBar_mc.barra._x)/segmento;
   my_sound.start(pos_nuevo,1);
   my_interval = setInterval(updateProgressBar, 100, my_sound);
}

Por Elena Mon

1 de clabLevel



 

firefox

 

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