Comunidad de diseño web y desarrollo en internet online

Error #2032 en IOErrorEvent

Citar            
MensajeEscrito el 22 Dic 2011 03:51 pm
Resulta que anda todo perfecto el streaming... el tema es cuando ejecuto la function del ProgressEvent..

Código ActionScript :

private function Progress(e:Event):void
      {
         ExternalInterface.call("Progress", Channel.position);
      }


por algun motivo al utilizar el ExternalInterface.call en el Progress... se corta la musica a los 2 segundos.. o ni empieza..
y la funcion de IOErrorEvent me tira el Error #2032...

Ahora bien saco la funcion ExternalInterface.call... y anda de maravilla

Alguna explicacion? :s

saludos

Por Fernand0

23 de clabLevel



Genero:Masculino  

Buenos Aires, Argentina

firefox
Citar            
MensajeEscrito el 22 Dic 2011 04:51 pm
Mira si solo esa llamada a JS no funciona o ninguna lo hace (¿tienes allowScriptAccess seteado en el html?)

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 22 Dic 2011 05:58 pm
Anda TODO, incluso muchas de las funciones de AS las manejo desde JS.. como Play.. Pause.. etc..
Pero cuando llega la hora del ExternalInterface pareciera como si "interrumpiera" el streaming :s

Aca dejo el codigo.. no es muy complejo

Código ActionScript :

package Audio
{
   
   import flash.net.URLLoader;
   import flash.net.URLRequest;
   import flash.net.URLVariables;
   import flash.net.URLRequestMethod;
   import flash.net.URLLoaderDataFormat;
   
   import flash.media.Sound;
   import flash.media.SoundChannel;
   import flash.media.SoundLoaderContext;
   
   import flash.events.Event;
   import flash.events.IOErrorEvent;
   import flash.events.ProgressEvent;
   
   import flash.external.ExternalInterface;
   
   
   public class Player
   {
      
      private var _Source:String = '/music/show/songs';
      private var _Loader:URLLoader;
      private var _Request:URLRequest;
      private var Variables:URLVariables;
      
      private var Song:Object = null;
      private var Songs:Array = null;
      
      private var sound:Sound = null;
      private var Channel:SoundChannel;
      private var Buffer:SoundLoaderContext;
      
      private var Position:Number = 0;
      private var Loading:Boolean = false;
      private var Playing:Boolean = false;
      private var Requesting:Boolean = false;


      public function Player():void
      {
         Buffer = new SoundLoaderContext(2*1000);
         
         _Loader = new URLLoader();
         _Loader.dataFormat = URLLoaderDataFormat.TEXT;
         _Loader.addEventListener(Event.COMPLETE, Response);
         
         Variables = new URLVariables();
      }
      
      
      public function Data(key:String, _value:String):void { Variables[key] = _value; }
      public function Source(source:String):void { _Source = source; }
      public function Request():void
      {
         if(Requesting) _Loader.close();
         
         _Request = new URLRequest(_Source);
         _Request.method = URLRequestMethod.POST;
         _Request.data = Variables;
         
         _Loader.load(_Request);
         
         Requesting = true;
      }
      
      function Response(e:Event):void
      {
         Requesting = false;
         
         var json:JSON = new JSON();
         
         Songs = json.Parse(e.target.data);
         Song = null;
      }
      
      
      public function Load(track:uint):void
      {
         Loading = true;
         
         unLoad();
         
         Song = Songs[track];
         sound = new Sound();
         addEvents();
         
         sound.load(new URLRequest(Song.url), Buffer);
      }
      
      private function unLoad():void
      {
         if(!sound) return;
         
         Stop();
         
         if(sound.isBuffering)
            sound.close();
         
         removeEvents();
      }
      
      
      private function addEvents():void
      {
         sound.addEventListener(Event.OPEN, Open);
         sound.addEventListener(Event.COMPLETE, Complete);
         sound.addEventListener(ProgressEvent.PROGRESS, Progress);
         sound.addEventListener(IOErrorEvent.IO_ERROR, ioError);
      }
      
      private function removeEvents():void
      {
         sound.removeEventListener(Event.OPEN, Open);
         sound.removeEventListener(Event.COMPLETE, Complete);
         sound.removeEventListener(ProgressEvent.PROGRESS, Progress);
         sound.removeEventListener(IOErrorEvent.IO_ERROR, ioError);
      }
      
      
      private function Open(e:Event):void
      {
         Loading = false;
         Play();
      }
      
      
      public function Play():void
      {
         if(!sound || Loading || Playing) return;
         
         Playing = true;
         
         Channel = sound.play(Position);
         Channel.addEventListener(Event.SOUND_COMPLETE, soundComplete);
      }
      
      public function Pause():void
      {
         if(!sound || Loading || !Playing) return;
         
         Playing = false;
         Position = Channel.position;
         
         Channel.stop();
         Channel.removeEventListener(Event.SOUND_COMPLETE, soundComplete);
      }
      
      public function Stop():void
      {
         if(!sound) return;
         
         Playing = false;
         Position = 0;
         
         Channel.stop();
         Channel.removeEventListener(Event.SOUND_COMPLETE, soundComplete);
      }
      
      
      private function Complete(e:Event):void { }
      
      private function Progress(e:Event):void
      {
         //ExternalInterface.call("Progress", "hola");
      }
      
      private function ioError(e:IOErrorEvent):void
      {
         Loading = false;
         Playing = false;
         
         ExternalInterface.call("alert", e.text);
      }
      
      private function soundComplete(e:Event):void
      {
         Playing = false;
         Position = 0;
         
         Channel.stop();
         Channel.removeEventListener(Event.SOUND_COMPLETE, soundComplete);
      }

   }
   
}


saludos y gracias

Por Fernand0

23 de clabLevel



Genero:Masculino  

Buenos Aires, Argentina

firefox
Citar            
MensajeEscrito el 23 Dic 2011 04:21 am
IOErrorEvent es cuando no puede leer un archivo. Así como lo tienes comentado, aunque no tenga sentido, ¿da error?

ExternalInterface.call("Progress", "hola");

Si no da error, posiblemente la llamada no logre acceder al archivo origen.

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 23 Dic 2011 05:38 am
Cuando el ExternalInterface.call esta comentado.. anda a la perfeccion, lo tuve que dejar con la linea comentada porque sino no me andaba el streaming bien

Por Fernand0

23 de clabLevel



Genero:Masculino  

Buenos Aires, Argentina

firefox

 

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