The plugin framework for OSMF can appear complicated at first glance, but from the point of view of a player developer, it’s actually fairly simple. Loading plugins can be as simple as one line of code added to an existing player. Early versions of the framework required the plugin exist on the same domain, but now the framework can load plugins cross domain, given that the player is hosted from an http:// url and the plugin is also hosted from an http:// url, and the plugin’s webserver has the appropriate cross-domain policy file in place. This means loading a player locally (using a file:// style url) won’t work with dynamic plugins. A local webserver is the suggested setup.
Using the PluginManager, a plugin can be loaded in one line of code. The following code snippet demonstrates how one might load a CDN plugin:
private var mediaPlayerWrapper:MediaPlayerWrapper = new MediaPlayerWrapper() ;
private static const REMOTEPROGRESSIVE:String = “http://mediapm.edgesuite.net/strobe/content/test/AFaerysTalesylviaApostol640500_short.flv”;
private static const PLUGIN_REMOTE:String = “http://example.com/samplePlugin.swf”;
private var manager:PluginManager;
private function init():void
manager = new PluginManager(new DefaultMediaFactory());
manager.loadPlugin(new URLResource(new URL(PLUGINREMOTE)));
private function onPlugin(event:Event):void
mediaPlayerWrapper.element = manager.mediaFactory.createMediaElement(new URLResource(new URL(REMOTE_PROGRESSIVE)));
private function onPluginFailed(event:Event):void
The above code snippet will attempt to load the plugin at http://example.com/samplePlugin.swf. This line needs to be changed to the location of the plugin the player wants loaded. For instance it can be changed to the location of the Akamai plugin, once Akamai releases their CDN plugin.
This feature releases the player developer from having to maintain plugin code. It allows bug fixes and updates to reach players using 3rd party plugins, without having to recompile players.