0 Replies Latest reply on Feb 26, 2010 1:22 AM by bugreport22

    Load local SWF Files with SMIL Plugin Adobe AIR

    bugreport22 Level 1



      I'm using the SMIL Plugin to load Media Elements for my player. Everything is working great when Im trying to load the standard SMIL File like:


      <smil xmlns="http://www.w3.org/2005/SMIL21/Language">
              <video region="content" src="http://mediapm.edgesuite.net/strobe/content/test/elephants_dream_768x428_24_short.flv" />


      but when I'm tryin to load a local SWF File which I created with Flex nothing happens and Im getting a violation error. When I try to load a simple .swf (I dont know how it is created mybe with adobe flash) it works. What can I do to load local swf files.


      here is my code which I'm using


      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" initialize="initApp();" width="1920" height="1080" layout="absolute">
                     import org.osmf.events.TimeEvent;
                     import org.osmf.smil.parser.SMILParser;
                     import org.osmf.containers.*;
                     import org.osmf.smil.model.SMILMediaElement;
                     import org.osmf.smil.model.SMILElement;
                     import org.osmf.media.MediaFactory;
                     import org.osmf.utils.URL;
                     import org.osmf.media.URLResource;
                     import mx.controls.Alert;
                     import org.osmf.events.PluginLoadEvent;
                     import org.osmf.plugin.PluginInfo;
                     import org.osmf.smil.SMILPluginInfo;
                     import org.osmf.plugin.PluginInfoResource;
                     import org.osmf.media.DefaultMediaFactory;
                     import org.osmf.plugin.PluginManager;
                     import org.osmf.media.*;
                     import org.osmf.display.MediaPlayerSprite;
                  import org.osmf.layout.LayoutUtils;
                  import org.osmf.containers.MediaContainer;
                     private var pluginManager:PluginManager;
                     private var mediaFactory:DefaultMediaFactory;
                     private var pluginElement:MediaElement;
                     private var sliderDragging:Boolean;
                     private var waitForSeek:Boolean;
                     private var pluginResourceMap:Dictionary;
                     private var container:MediaContainer;
                     private var mediaPlayer:MediaPlayer;
                     private static const SMIL_PLUGIN_INFOCLASS:String = "org.osmf.smil.SMILPluginInfo";
                     private static const SMIL_TEST_4:String                    = "http://localhost/seq-test.smil";
                     public function initApp():void {
                          mediaFactory = new DefaultMediaFactory();
                          pluginManager = new PluginManager(mediaFactory);
                          var v:SMILPluginInfo;
                     private function loadMedia(url:String):void
                          try {
                               var resource:URLResource = new URLResource(new URL(url)); 
                               var mediaElement:MediaElement = mediaFactory.createMediaElement(resource);
                               container = new MediaContainer(); 
                           // feed the display object a media element
                           container.addMediaElement( mediaElement ); 
                           // Flex requires a DisplayObject to be wrapped in Flex Framework UI Abstraction
                           videoParent.addChild( container ); 
                           // MediaPlayer is a virtual controller. Assign it a media element and it will autoplay the media by default.
                           mediaPlayer = new MediaPlayer( mediaElement );
                             catch(error:Error) {
                      //LayoutUtils.setAbsoluteLayout( mediaElement.metadata, 1920, 1080 );
                     private function loadPlugin():void
                          var pluginResource:MediaResourceBase;
                               // Assume this is a class
                          var pluginInfoRef:Class = flash.utils.getDefinitionByName(SMIL_PLUGIN_INFOCLASS) as Class;
                          pluginResource = new PluginInfoResource(new pluginInfoRef);
                          if (pluginResourceMap == null)
                               pluginResourceMap = new Dictionary();
                          pluginResourceMap[SMIL_PLUGIN_INFOCLASS] = pluginResource;
                     private function loadPluginFromResource(pluginResource:MediaResourceBase):void
                          pluginManager.addEventListener(PluginLoadEvent.PLUGIN_LOADED, onPluginLoaded);
                          pluginManager.addEventListener(PluginLoadEvent.PLUGIN_LOAD_FAILED, onPluginLoadFailed);
                     private function onPluginLoaded(event:PluginLoadEvent):void
                     private function onPluginLoadFailed(event:PluginLoadEvent):void
                          Alert.show("Plugin LOAD FAILED: ");
            <mx:UIComponent id="videoParent"/>