29 Replies Latest reply on Jul 4, 2011 2:00 AM by AmigoCaracas

    Problem following the plugin_dev_guide.pdf with dynamic plugin (swf format)


      I am lerning about OSMF
      till now I can crate a simple video player, and I want to connect with a dynamic plugin

      following the sample from plugin_dev_guide.pdf I have a problem to load the plug in
      I get the folloing error when I debug it:
      [SWF] C:\alex\PlayerCDN\visor2\bin-debug\visor2.swf - 605,222 bytes after decompression
      [SWF] C:\alex\PlayerCDN\lib\PlugIN_junio.swf - 1,358 bytes after decompression
      plugin load error
      [Unload SWF] C:\alex\PlayerCDN\lib\PlugIN_junio.swf

      In the Video Player (Flash Builder): //Name:Plugin
      import org.osmf.events.MediaFactoryEvent;
      import org.osmf.media.DefaultMediaFactory;
      import flash.events.MouseEvent;
      import flash.display.Graphics;
      import org.osmf.events.PlayEvent;
      import flash.display.Sprite;
      import org.osmf.containers.MediaContainer;
      import org.osmf.media.DefaultMediaFactory;
      import org.osmf.media.MediaElement;
      import org.osmf.media.MediaFactory;
      import org.osmf.media.MediaPlayer;
      import org.osmf.media.URLResource;
      [SWF(width="800", height="600")]

      public class visor2 extends Sprite
        protected var factory:MediaFactory;

        public function visor2()

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

         //var resource:URLResource = new URLResource("file://C:/alex/PlayerCDN/lib/com.akamai.osmf.AkamaiBasicStreamingPluginInfo");
         var resource:URLResource = new URLResource("file://C:/alex/PlayerCDN/lib/PlugIN_junio.swf");
         //var resource:URLResource = new URLResource("file://C:/alex/PlayerCDN/lib/pluginCDN2.swf");

        private function onPluginLoad(event:MediaFactoryEvent):void
         // Create the container class that displays the media.
         var container:MediaContainer = new MediaContainer();
         //Create a new DefaultMediaFactory
         var mediaFactory:MediaFactory = new DefaultMediaFactory();
         // Create the resource to play.
         var resource:URLResource = new URLResource("http://mediapm.edgesuite.net/strobe/content/test/SpaceAloneHD_sounas_640_500_short.flv");

         var mediaElement:MediaElement = mediaFactory.createMediaElement(resource);

         var mediaPlayer:MediaPlayer = new MediaPlayer();
         mediaPlayer.media = mediaElement;
        private function onPluginLoadError(event:MediaFactoryEvent):void
         trace('plugin load error');


      in the plugin (flash cs5): Name:PlugIN_junio.swf

      // Root object which exposes the PluginInfo object.
      public class HelloWorldPlugin extends Sprite
      public function HelloWorldPlugin()
      _pluginInfo = new HelloWorldPluginInfo();
      // OSMF will invoke this getter to retrieve the plug-in's
      // PluginInfo object.
      public function get pluginInfo():PluginInfo
      return _pluginInfo;
      private var _pluginInfo:PluginInfo;
      // The PluginInfo object.
      public class HelloWorldPluginInfo extends PluginInfo
      public function HelloWorldPluginInfo()
      var items:Vector.<MediaFactoryItem> = new Vector.<MediaFactoryItem>();
      // Create the MediaFactoryItem and add to our list of items.
      var item:MediaFactoryItem = new MediaFactoryItem
      ( "helloworld"
      , canHandleResourceFunction
      , mediaElementCreationFunction
      ( "com.example.helloworld"
      , canHandleResourceFunction
      , mediaElementCreationFunction
      // Pass the list to the base class.
      // to MediaFactory.createMediaElement. The method must take a single
      // parameter of type MediaResourceBase and return a Boolean. The
      // plug-in should return true if it can create a MediaElement for that
      // resource.
      private function canHandleResourceFunction(resource:MediaResourceBase):Boolean
      var result:Boolean = false;
      // Only return true if the resource is an URLResource...
      var urlResource:URLResource = resource as URLResource;
      if (urlResource != null)
      // ... and if the URL starts with "rtmp".
      result = urlResource.url.indexOf("rtmp") == 0;
      return result;
      // OSMF will invoke this function for any resource that is passed to
      // MediaFactory.createMediaElement, and for which the corresponding
      // canHandleResourceFunction returns true. The method must take
      // no parameters and return a MediaElement.
      private function mediaElementCreationFunction():MediaElement
      return new VideoElement();


      Please, I need some help to load it
      Now I am doing it locally, but after I want to load from the web
      now I want just to load it, then I want to modify the plugin.
      I am reading but I cant find any example in the web
      I think the problem is in the plugin