9 Replies Latest reply on Aug 16, 2011 12:51 AM by Alex_Birchler

    problem with the player

    Alex_Birchler Level 1

      Hi
      I need to connect the plugin to a player, but in this case, the client owner of the player dont want to
      import the osmf.swc.
      He doesnt want to do that, he can change some code in the player, but dont want to import the OSMF.swc package.
      Is possible to send from the player the video object to a class, and then in that class I can get it, and send it to
      the plugin, or another class that work like bridge?

      thanks

        • 1. Re: problem with the player
          Alex_Birchler Level 1

          in this case, I send from the player the media like this:

           

          var sendMedia:bridge = new bridge();
                     
          var _sendMedia2 = sendMedia.inicio(myVideo1);

           

          and in the "bridge", I get the video object with this code:

           

          package {

           

              import flash.display.MovieClip;
              import flash.display.Sprite;
              import flash.events.ErrorEvent;
              import flash.events.MouseEvent;
              import flash.ui.Keyboard;
              import flash.text.TextField;

           

              import org.osmf.containers.MediaContainer;
              import org.osmf.elements.HTMLElement;
              import org.osmf.elements.ImageElement;
              import org.osmf.events.DisplayObjectEvent;
              import org.osmf.events.MediaErrorEvent;
              import org.osmf.events.MediaFactoryEvent;
              import org.osmf.events.TimeEvent;
              import org.osmf.layout.LayoutMetadata;
              import org.osmf.layout.ScaleMode;
              import org.osmf.media.DefaultMediaFactory;
              import org.osmf.media.MediaElement;
              import org.osmf.media.MediaFactory;
              import org.osmf.media.MediaPlayer;
              import org.osmf.metadata.Metadata;
              import org.osmf.traits.LoadTrait;
              import org.osmf.traits.MediaTraitType;
             
              import org.osmf.elements.VideoElement;
              import org.osmf.media.URLResource;
              import org.osmf.utils.URL;
             
              public class bridge extends MovieClip
              {   
             
                  var resourcePI:URLResource = new URLResource ("http://localhost/plugins/CDNPlugin.swf");
                  var mediaElement:MediaElement;
                 
                 
                  public var player:MediaPlayer;
                  public var container:MediaContainer;
                  public var mediaFactory:DefaultMediaFactory;  // I get error

           

                 
                  public function inicio(media){
                      trace("entramos en inicio " + media);
                     
                      initPlayer(media);

           

                      var factory:MediaFactory = new DefaultMediaFactory();
                      factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD, onPluginLoad);
                      factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD_ERROR, onPluginLoadError);
                     
                     
                      factory.loadPlugin(resourcePI);

           

                     
                  }
              }
          }

           

          I get an error once I uncomment public var mediaFactory:DefaultMediaFactory;
          I used to use the plugin constructor
          but if is uncomment, become an error
          why is this?
          this are the error codes I get in firebug:
          VerifyError: Error #1053: Illegal override of play2 in org.osmf.net.httpstreaming.HTTPNetStream.
          ReferenceError: Error #1065: Variable mute_button is not defined.
          ReferenceError: Error #1065: Variable play-pause is not defined.
          ReferenceError: Error #1065: Variable Main is not defined.

          • 2. Re: problem with the player
            Alex_Birchler Level 1

            well, was my mistake
            I was compipling the swf for flash player 9
            big mistake

            • 3. Re: problem with the player
              Alex_Birchler Level 1

              well
              Till now, I can load the plugin, but I can´t send the video reference
              Is received as null
              if I trace the element that I am sending, I receive a "VideoElement"
              But I can´t take information from it
              any help?

              • 4. Re: problem with the player
                Alex_Birchler Level 1

                if in the bridge.as file, I write this:
                var media:MediaElement = new MediaElement;
                I get this:
                TypeError: Error #1034: Type Coercion failed: cannot convert SimpleVideo@4a7b741 to org.osmf.media.MediaElement.
                at Main()
                can´t convert?

                • 5. Re: problem with the player
                  Alex_Birchler Level 1

                  Hi

                  had anybody that problem?

                  I mean, the project to get information of the video from a normal video, that is not using OSMF?

                  I am using an AS file with OSMF, like bridge

                  • 6. Re: problem with the player
                    Alex_Birchler Level 1

                    I explain what I am doing
                    I can´t detect where I have the mistake.
                    Please, if anybody can help me...

                     

                    First, I have the OSMF.swc at the flash lib folder, like always
                    In the player I have this to send the video to the bridge class :

                     

                        myVideo1 = new SimpleVideo("http://www.alexbirchler.com/SMP/f2.flv","",true);

                     

                        myVideo1.videoPlayerWidth = 450;
                       
                        myVideo1.x = 58,
                        myVideo1.y = 10;
                        myVideo1.setVolume(0);
                        addChild(myVideo1);

                     

                        var numero:Number = 30;
                               
                        var sendMedia:bridge = new bridge();
                       
                        var _sendMedia2 = sendMedia.inicio(myVideo1);

                     

                    here I send the video objet to the bridge class ( I think that I am doing right)

                     

                    in the bridge class I have this:

                     

                        public class bridge extends MovieClip
                        {   
                           
                            var resourcePI:URLResource = new URLResource ("http://localhost/plugins/CDNPlugin.swf");
                            var mediaElement:MediaElement;
                            var media:MediaElement;
                           
                            public var player:MediaPlayer;
                            public var container:MediaContainer;
                            public var mediaFactory:DefaultMediaFactory;

                     


                            public function inicio(media):void{

                     

                                var factory:MediaFactory = new DefaultMediaFactory();
                                factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD, onPluginLoad);
                                factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD_ERROR, onPluginLoadError);
                               
                                factory.loadPlugin(resourcePI);
                               
                                resourcePI.addMetadataValue("_UserIP", '10.20.30.48');
                               
                           
                                initPlayer(media);
                                           
                               
                            }
                           
                            public function onPluginLoad(event:MediaFactoryEvent):void
                            {
                                initPlayer(media);
                                trace("plugin cargado con exito");

                     

                            }

                     

                            private function onPluginLoadError(event:MediaFactoryEvent):void
                            {
                                trace('plugin load error');
                            }
                           
                            protected function initPlayer(media)
                            {
                                //trace("entramos en initPlayer del puente");
                                var resource:URLResource = new URLResource( media );

                     

                                mediaFactory = new DefaultMediaFactory();
                               
                                var element:MediaElement = mediaFactory.createMediaElement( resource );

                     

                                player = new MediaPlayer( element );

                     

                                player.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError);
                               
                                function onMediaError(event:MediaErrorEvent):void
                                {
                                    trace("detectamos un error");
                                    var errMsg:String = "Media error : code="+event.error.errorID+" description="+event.error.message;
                                   
                                    trace(errMsg);
                                }

                     

                                var meta:Metadata = new Metadata()
                                meta.addValue("contentElement", element);
                                resourcePI.addMetadataValue("marker", meta); //enviamos referencia al plugin via metadata
                                //trace("ya nos llevamos la referencia")
                            }
                        }

                     

                    I can load the plugin, but the problem is that I can´t take information from the video, like duration and others.

                     

                    If I load the plugin from a main project with the video (without passing throw bridge) then is ok, and everything is going correct

                     

                    I need to load the plugin using a bridge because I have a project where the client dont want to use OSMF, I mean, they dont want to modify their player

                     

                    can anybody help me?
                    thanks a lot

                    • 7. Re: problem with the player
                      Alex_Birchler Level 1

                      If I add the following lines:

                       

                              container = new MediaContainer();
                             
                              player.stop(); //this is causing a problem

                       

                      then I get the following error message:

                       

                      Error: The specified capability is not currently supported
                      at org.osmf.media::MediaPlayer/getTraitOrThrow()
                      at org.osmf.media::MediaPlayer/stop()
                      at bridge/initPlayer()
                      at bridge/inicio()
                      at Main()

                       

                      the modification is:

                       


                          public class bridge extends MovieClip
                          {  
                            
                              var resourcePI:URLResource = new URLResource ("http://localhost/plugins/CDNPlugin.swf");
                              var mediaElement:MediaElement;
                              var media:MediaElement;
                            
                              public var player:MediaPlayer;
                              public var container:MediaContainer;
                              public var mediaFactory:DefaultMediaFactory;

                       

                       

                       


                              public function inicio(media):void{

                       

                       

                       

                                  var factory:MediaFactory = new DefaultMediaFactory();
                                  factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD, onPluginLoad);
                                  factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD_ERROR, onPluginLoadError);
                                
                                  factory.loadPlugin(resourcePI);
                                
                                  resourcePI.addMetadataValue("_UserIP", '10.20.30.48');
                                
                            
                                  initPlayer(media);
                                            
                                
                              }
                            
                              public function onPluginLoad(event:MediaFactoryEvent):void
                              {
                                  initPlayer(media);
                                  trace("plugin cargado con exito");

                       

                       

                       

                              }

                       

                       

                       

                              private function onPluginLoadError(event:MediaFactoryEvent):void
                              {
                                  trace('plugin load error');
                              }
                            
                              protected function initPlayer(media)
                              {
                                  //trace("entramos en initPlayer del puente");
                                  var resource:URLResource = new URLResource( media );

                       

                       

                       

                                  mediaFactory = new DefaultMediaFactory();
                                
                                  var element:MediaElement = mediaFactory.createMediaElement( resource );

                       

                       

                       

                                  player = new MediaPlayer( element );
                         
                              container = new MediaContainer();
                             
                              //player.stop(); //this is causing a problem

                       

                       

                       

                                  player.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError);
                                
                                  function onMediaError(event:MediaErrorEvent):void
                                  {
                                      trace("detectamos un error");
                                      var errMsg:String = "Media error : code="+event.error.errorID+" description="+event.error.message;
                                    
                                      trace(errMsg);
                                  }

                       

                       

                       

                                  var meta:Metadata = new Metadata()
                                  meta.addValue("contentElement", element);
                                  resourcePI.addMetadataValue("marker", meta); //enviamos referencia al plugin via metadata
                                  //trace("ya nos llevamos la referencia")
                              }
                          }

                       

                      I think I am not passing the video object correctly

                      • 8. Re: problem with the player
                        Alex_Birchler Level 1

                        the video is loading via sent from the player like "media", but if I modify it and I load the video directly
                        then is ok:

                         

                        var LOCAL_SWF:String = "http://localhost/f2.flv";
                        var resource:URLResource = new URLResource( LOCAL_SWF );
                        //var resource:URLResource = new URLResource( media );

                         


                            public class bridge extends MovieClip
                            {  
                              
                                var resourcePI:URLResource = new URLResource ("http://localhost/plugins/CDNPlugin.swf");
                                var mediaElement:MediaElement;
                                var media:MediaElement;
                              
                                public var player:MediaPlayer;
                                public var container:MediaContainer;
                                public var mediaFactory:DefaultMediaFactory;

                         

                         

                         


                                public function inicio(media):void{

                         

                         

                         

                                    var factory:MediaFactory = new DefaultMediaFactory();
                                    factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD, onPluginLoad);
                                    factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD_ERROR, onPluginLoadError);
                                  
                                    factory.loadPlugin(resourcePI);
                                  
                                    resourcePI.addMetadataValue("_UserIP", '10.20.30.48');
                                  
                              
                                    initPlayer(media);
                                              
                                  
                                }
                              
                                public function onPluginLoad(event:MediaFactoryEvent):void
                                {
                                    initPlayer(media);
                                    trace("plugin cargado con exito");

                         

                         

                         

                                }

                         

                         

                         

                                private function onPluginLoadError(event:MediaFactoryEvent):void
                                {
                                    trace('plugin load error');
                                }
                              
                                protected function initPlayer(media)
                                {
                                    //trace("entramos en initPlayer del puente");
                                    var LOCAL_SWF:String = "http://localhost/f2.flv";
                                    var resource:URLResource = new URLResource( LOCAL_SWF );
                                   //var resource:URLResource = new URLResource( media );

                         

                         

                         

                                    mediaFactory = new DefaultMediaFactory();
                                  
                                    var element:MediaElement = mediaFactory.createMediaElement( resource );

                         

                         

                         

                                    player = new MediaPlayer( element );
                           
                                container = new MediaContainer();
                               
                                //player.stop(); //this is causing a problem

                         

                         

                         

                                    player.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError);
                                  
                                    function onMediaError(event:MediaErrorEvent):void
                                    {
                                        trace("detectamos un error");
                                        var errMsg:String = "Media error : code="+event.error.errorID+" description="+event.error.message;
                                      
                                        trace(errMsg);
                                    }

                         

                         

                         

                                    var meta:Metadata = new Metadata()
                                    meta.addValue("contentElement", element);
                                    resourcePI.addMetadataValue("marker", meta); //enviamos referencia al plugin via metadata
                                    //trace("ya nos llevamos la referencia")
                                }
                            }

                         

                        but as I said, I want to get the video Object from the player and send it to the bridge

                        • 9. Re: problem with the player
                          Alex_Birchler Level 1

                          Ok, I got the solution
                          I modified the player with the following code lines:

                           

                                      var LOCAL_SWF:String = "http://localhost/f2.flv";
                                      myVideo1 = new SimpleVideo(LOCAL_SWF,"",true);
                                      myVideo1.videoPlayerWidth = 450;
                                     
                                      myVideo1.x = 58,
                                      myVideo1.y = 10;
                                      myVideo1.setVolume(0);
                                      addChild(myVideo1);
                                      var numero:Number = 30;
                                      var sendMedia:bridge = new bridge();
                                      var _sendMedia2 = sendMedia.inicio(LOCAL_SWF); //video element

                           

                          we send the video link, not the object
                          Is that correct?
                          now is working but I dont know if I am doing in the correct way

                           


                              public class bridge extends MovieClip
                              {  
                                
                                  var resourcePI:URLResource = new URLResource ("http://localhost/plugins/CDNPlugin.swf");
                                  var mediaElement:MediaElement;
                                  var media:MediaElement;
                                
                                  public var player:MediaPlayer;
                                  public var container:MediaContainer;
                                  public var mediaFactory:DefaultMediaFactory;

                           

                           

                           


                                  public function inicio(media):void{

                           

                           

                           

                                      var factory:MediaFactory = new DefaultMediaFactory();
                                      factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD, onPluginLoad);
                                      factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD_ERROR, onPluginLoadError);
                                    
                                      factory.loadPlugin(resourcePI);
                                    
                                      resourcePI.addMetadataValue("_UserIP", '10.20.30.48');
                                    
                                
                                      initPlayer(media);
                                                
                                    
                                  }
                                
                                  public function onPluginLoad(event:MediaFactoryEvent):void
                                  {
                                      initPlayer(media);
                                      trace("plugin cargado con exito");

                           

                           

                           

                                  }

                           

                           

                           

                                  private function onPluginLoadError(event:MediaFactoryEvent):void
                                  {
                                      trace('plugin load error');
                                  }
                                
                                  protected function initPlayer(media)
                                  {
                                      //trace("entramos en initPlayer del puente");
                                      var LOCAL_SWF:String = "http://localhost/f2.flv";
                                  var resource:URLResource = new URLResource( LOCAL_SWF );
                                  //var resource:URLResource = new URLResource( media );

                           

                           

                           

                                      mediaFactory = new DefaultMediaFactory();
                                    
                                      var element:MediaElement = mediaFactory.createMediaElement( resource );

                           

                           

                           

                                      player = new MediaPlayer( element );
                             
                                  container = new MediaContainer();
                                 
                                  //player.stop(); //this is causing a problem

                           

                           

                           

                                      player.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError);
                                    
                                      function onMediaError(event:MediaErrorEvent):void
                                      {
                                          trace("detectamos un error");
                                          var errMsg:String = "Media error : code="+event.error.errorID+" description="+event.error.message;
                                        
                                          trace(errMsg);
                                      }

                           

                           

                           

                                      var meta:Metadata = new Metadata()
                                      meta.addValue("contentElement", element);
                                      resourcePI.addMetadataValue("marker", meta); //enviamos referencia al plugin via metadata
                                      //trace("ya nos llevamos la referencia")
                                  }
                              }