Instructions for Adobe OSMF Player (1.0) The Anvato Analytics Plugin for Adobe Open Source Media Framework is a small flash module that is dynamicly loaded to player and tracks video, user and ads statistics. Any Adobe OSMF based flash players can load this module dynamically. Once activated, it will collect statistics and deliver them to the Anvato Analytics server farm so that you can view analytics online at analytics.anvato.com . Because the plug-in sends data silently to your Anvato analytics account, you will not notice anything different about your player after it is installed.
Integrating Anvato Analytics with an existing instance of the OSMF player is simple: Anvato Anlaytics plugin should be loaded after initialization of the player but player loads any video. OSMF has already plugin architecture and plugin loading class to make it simple. Download example source code to see how the anlaytics plugin dynamicly loaded onto OSMF player. Following code piece shows how to initialziae the plugin and load Anvato Anlaytics plugin to OSMF player.
import com.anvato.plugin.Loader; [Frame(factoryClass="org.osmf.player.preloader.Preloader")] [SWF(backgroundColor="0x000000", frameRate="25", width="640", height="380")] public class OSMFPlayer extends ChromeApplication { private var anvatoPluginLoader:com.anvato.plugin.Loader; private var anvatoAnalytics:Object = null; private var parameters:Object = null; public function OSMFPlayer(preloader:Preloader) { // Get a reference to the stage from the preloader (ours isn't set yet). _stage = preloader.stage; // Store pre-loader references: CONFIG::DEBUG { debugger = preloader.debugger; Log.loggerFactory = new DebuggerLoggerFactory(preloader.debugger); } super(); // Set the SWF scale mode, and listen to the stage change // dimensions: _stage.scaleMode = StageScaleMode.NO_SCALE; _stage.align = StageAlign.TOP_LEFT; _stage.addEventListener(Event.RESIZE, onStageResize); // Parse configuration from the parameters passed on embedding // OSMFPlayer.swf: configuration = new PlayerConfiguration(preloader.loaderInfo.parameters); parameters = preloader.loaderInfo.parameters; // Setup the ChromeApplication (base class): setup(preloader.configuration); } // Internals // override protected function processSetupComplete():void { player.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError); player.addEventListener(MediaPlayerCapabilityChangeEvent.IS_DYNAMIC_STREAM_CHANGE, onIsDynamicStreamChange); player.autoPlay = true; container.clipChildren = true; container.backgroundColor = configuration.backgroundColor; container.backgroundAlpha = isNaN(configuration.backgroundColor) ? 0 : 1; var urlInput:URLInput = widgets.getWidget("urlInput") as URLInput; if (urlInput) { urlInput.addEventListener(Event.CHANGE, onInputURLChange); urlInput.url = configuration.url; } var button:EjectButton = widgets.getWidget("ejectButton") as EjectButton; if (button) { button.addEventListener(MouseEvent.CLICK, onEjectButtonClick); } alert = widgets.getWidget("alert") as AlertDialog; // Simulate the stage resizing, to update the dimensions of the // container: onStageResize(); // load Anvato analytics Plugins if (!anvatoPluginLoader){ anvatoPluginLoader = new com.anvato.plugin.Loader(); anvatoPluginLoader.config['factory'] = factory; if (parameters.tracker) anvatoPluginLoader.addPlugin('analytics'); anvatoPluginLoader.addEventListener(com.anvato.plugin.Loader.PLUGINS_READY,initVideo); anvatoPluginLoader.loadPlugins(); } } private function initVideo(e:Event):void{ // Try to load the URL set on the configuration: url = configuration.url; }
Make sure pass tracker and video title to analytics plugin when loading a video
override protected function processNewMedia(value:MediaElement):MediaElement { var result:MediaElement = value; if (result != null) { // Forward the configuration's auto-hide setting: var metadata:Metadata = new Metadata(); metadata.addValue(ChromeMetadata.AUTO_HIDE, configuration.autoHideControlBar); result.addMetadata(ChromeMetadata.CHROME_METADATA_KEY, metadata); // If not auto-playing, watch the player become seekable, once: if (configuration.autoPlay == false) { player.addEventListener ( MediaPlayerCapabilityChangeEvent.CAN_SEEK_CHANGE , onCanSeekChange ); function onCanSeekChange(event:MediaPlayerCapabilityChangeEvent):void { player.removeEventListener(PlayEvent.PLAY_STATE_CHANGE, onCanSeekChange); if (player.canPause) { player.pause(); if (player.canSeek && player.canSeekTo(0.001)) { player.seek(0.001); } } } } // When in debugging mode, wrap the element in a debugger proxy: CONFIG::DEBUG { result = new DebuggerElementProxy(value, debugger); debugger.send("TRACE", "media change", value); } try { for(var obj:Object = value;obj;) { try { if(obj as VideoElement) break; //find the plugin if(obj.name == "anvato.analytics"){ anvatoAnalytics = obj; anvatoAnalytics.config['tracker'] = parameters.tracker; anvatoAnalytics.config['debug'] = 'true'; anvatoAnalytics.config['title'] = parameters.title; anvatoAnalytics.config['url'] = configuration.url; anvatoAnalytics.initialize(); anvatoAnalytics.listenComponent(this); } obj = obj.proxiedElement } catch(e:Error) { obj = obj.proxiedElement } } } catch(e:Error) { trace(e.getStackTrace()); } } return result; }