What does the "Export APIs to Window object" option in Launch do for the Media 3.x Extension? | Community
Skip to main content
Level 2
February 7, 2023
Question

What does the "Export APIs to Window object" option in Launch do for the Media 3.x Extension?

  • February 7, 2023
  • 1 reply
  • 770 views

For the Media Analytics 3.x extension, there's an option to toggle on `Export APIs to Window object`. The documentation isn't clear on the purpose of this configuration. Can someone please help explain when this should be enabled?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

yuhuisg
Community Advisor
Community Advisor
February 8, 2023

Based on my reading of the extension's source code and Media Analytics' documentation:

In a normal JavaScript implementation, Media Analytics would expose a "ADB" object. That object has a "ADB.Media" key that itself exposes certain functions that are used with Media Analytics tracking.

The "Export APIs to Window object" toggle seems to make the properties and functions provided in "ADB.Media" to be available at a global window scope.

In the extension's setting, you need to set a variable name. I think this can be whatever you want, e.g. "MyMediaAnalytics". So with the "Export APIs to Window object" toggle turned on and with this variable name, the result is that in your web page, you should have the following:

 

window.MyMediaAnalytics = { Media: { Event : ADB.Media.Event, MediaType : ADB.Media.MediaType, StreamType : ADB.Media.StreamType, PlayerState: ADB.Media.PlayerState, MediaObjectKey : ADB.Media.MediaObjectKey, VideoMetadataKeys : ADB.Media.VideoMetadataKeys, AudioMetadataKeys : ADB.Media.AudioMetadataKeys, AdMetadataKeys : ADB.Media.AdMetadataKeys, version : ADB.Media.version, createMediaObject : ADB.Media.createMediaObject, createAdBreakObject : ADB.Media.createAdBreakObject, createAdObject : ADB.Media.createAdObject, createChapterObject : ADB.Media.createChapterObject, createQoEObject : ADB.Media.createQoEObject, createStateObject: ADB.Media.createStateObject, getInstance: ADB.Media.getInstance } }

 

So, for example, if in a normal Media Analytics JavaScript implementation, you need to set a tracker with ADB.Media.getInstance(), then you would run:

 

var tracker = window.MyMediaAnalytics.Media.getInstance();

 

Note: as I've disclaimed at the start, the above is based on my reading of the extension's source code. I suggest that you try this out by enabling the toggle and providing a variable name, then running "window.[variable name]" in your browser console to see if you get back the expected object like I've listed above.