7 Replies Latest reply on Dec 15, 2010 2:21 AM by Andrian Cucu

    ProxyElement plugin and instance ?

    Coco213 Level 1

      Hello,

       

      I'm trying to understand how the ProxyPlugin works and is instancied. When I lunch a playlist with a .m3u files, the class is instancied 3 times.

       

      Here is my ProxyElement class :

       

           public class BitmapProxyElement extends ProxyElement
           {
                
                public function BitmapProxyElement(proxiedElement:MediaElement)
                {
                     trace ("BitmapProxyElement");
                     
                     super(proxiedElement);
                }
                
                override public function set proxiedElement(value:MediaElement):void
                {
                     trace('override set proxy');
                     trace('value: ' + value);
                     
                     super.proxiedElement = value;
                     
                }
                }
      ...
      
      
      

       

      And here is the output

       

       

      BitmapProxyElement
      override set proxy
      value: null
      override set proxy
      value: [object PlaylistElement]
      [SWF] /StrobeMediaPlayback_1.5.Sprint4-full/src/player/... 
      BitmapProxyElement
      override set proxy
      value: null
      override set proxy
      value: [object VideoElement]
      BitmapProxyElement
      override set proxy
      value: null
      override set proxy
      value: [object VideoElement]
      

       

      I'd like to know why the plugin is instancied so many times ?

       

      And is there any way to unload initialized stuff (from an event for instance) when there is a new instance of a ProxyElement ?

       

       

      Thanks !

        • 1. Re: ProxyElement plugin and instance ?
          Andrian Cucu Adobe Employee

          Hi,

           

          Can you paste the code of your PluginInfo?

           

          I assume that you need to move some code away from its constructor.

           

          Thanks,

          Andrian

          • 2. Re: ProxyElement plugin and instance ?
            Coco213 Level 1

            Hi Andrian,

             

            My PluginInfo is trivial :

             

                 public class ProxyPluginInfo extends PluginInfo
                 {
                      private var _stage:Stage;
                      
                      public function ProxyPluginInfo(stage:Stage)
                      {
                           _stage = stage ;
                                          
                           var items:Vector.<MediaFactoryItem> = new Vector.<MediaFactoryItem>();
                           // Create the MediaFactoryItem and add to our list of items.
                           var item:MediaFactoryItem = new MediaFactoryItem
                                ( "com.example.proxyplugin"
                                     , canHandleResourceFunction
                                     , mediaElementCreationFunction
                                     , MediaFactoryItemType.PROXY
                                );
                           items.push(item);
                           // Pass the list to the base class.
                           super(items);
                           
                           trace ("plugin loaded");
                      }
            
                      private function canHandleResourceFunction(resource:MediaResourceBase):Boolean
                      {
                           var result:Boolean = false;
                                      var urlResource:URLResource = resource as URLResource;
                           if (urlResource != null)
                                     {
                                   result = true ;
                           }
                           
                           return result;
                      }
            
                      private function mediaElementCreationFunction():MediaElement
                      {
                           return new BitmapProxyElement(null);
                      }
            }
            

             

            Regards

            • 3. Re: ProxyElement plugin and instance ?
              Andrian Cucu Adobe Employee

              Can you also paste the content of your m3u file?

              • 4. Re: ProxyElement plugin and instance ?
                Coco213 Level 1

                It's a really simple playlist :

                 

                http://localhost.../video_1.mp4
                http://localhost.../video_2.mp4

                 

                Thanks for your help :-)

                • 5. Re: ProxyElement plugin and instance ?
                  Andrian Cucu Adobe Employee

                  Ok, I got it.

                   

                  The playlist implementation in Strobe Media Playback will create a ProxyElement which will switch between the videos in the playlist whenever you move from one item to another.

                   

                  So for a playlist of 2 elements there will be 3 instances of MediaElement created.

                   

                  Each of these elements will be wrapped in the ProxyElement that you create in your Proxy plugin... Does this make sense?

                   

                  Is this explanation consistent with the behavior you experience?

                   

                  Thank You,

                  Andrian

                  • 6. Re: ProxyElement plugin and instance ?
                    Coco213 Level 1

                    Hi Andrian,

                     

                    Actually, the output I showed before is just after the first video is loaded ... this is why I don't really understand what's going on !

                     

                    Regards

                    • 7. Re: ProxyElement plugin and instance ?
                      Andrian Cucu Adobe Employee

                      Hi Coco213,

                       

                      The m3u file is parsed and MediaElements are being created for each item, even if the actual media is being loaded later.

                       

                      -Andrian