Refer to the Getting Started Guide
APIs |
---|
extensionVersion |
registerExtensions |
createTracker |
createTrackerWithConfig |
createMediaObject |
createAdBreakObject |
createAdObject |
createChapterObject |
createQoEObject |
createStateObject |
APIs |
---|
trackSessionStart |
trackPlay |
trackPause |
trackComplete |
trackSessionEnd |
trackError |
trackEvent |
updateCurrentPlayhead |
updateQoEObject |
The extensionVersion() API returns the version of the Media for Edge Network extension that is used to register with the Mobile Core extension.
public static String extensionVersion() {
String mediaExtensionVersion = Media.extensionVersion();
val mediaExtensionVersion = Media.extensionVersion()
Represents a reference to MediaExtension.class that can be used to register with MobileCore via its registerExtensions api.
public static final Class<? extends Extension> EXTENSION = MediaExtension.class;
Refer MobileCore registerExtensions API.
MobileCore.registerExtensions(Arrays.asList(Media.EXTENSION, ...), new AdobeCallback<Object>() {
// implement completion callback
});
MobileCore.registerExtensions(listOf(Media.EXTENSION, ...)){
// implement completion callback
}
Creates a media tracker instance that tracks the playback session. The tracker created should be used to track the streaming content and it sends periodic pings to the media analytics backend.
public static MediaTracker createTracker()
MediaTracker tracker = Media.createTracker()
val tracker = Media.createTracker()
Creates a media tracker instance based on the configuration to track the playback session.
Key | Description | Value | Required |
---|---|---|---|
config.channel |
Channel name for media. Set this to overwrite the channel name configured in the Data Collection UI for media tracked with this tracker instance. | String | No |
config.mainpinginterval |
Overwrites the default main content tracking interval (in seconds) . The value should be in the allowed range [10-50] seconds . The default value is 10 seconds. |
Int | No |
config.adpinginterval |
Overwrites the default ad content tracking interval (in seconds) . The value should be in the allowed range [1-10] seconds . The default value is 10 seconds. |
Int | No |
public static MediaTracker createTracker(Map<String, Object> config)
HashMap<String, Object> config = new HashMap<String, Object>();
config.put(MediaConstants.TrackerConfig.CHANNEL, "custom-channel"); // Overwrites channel configured in the Data Collection UI.
config.put(MediaConstants.TrackerConfig.AD_PING_INTERVAL, 1); // Overwrites ad content ping interval to 1 second.
config.put(MediaConstants.TrackerConfig.MAIN_PING_INTERVAL, 30); // Overwrites main content ping interval to 30 seconds.
MediaTracker mediaTracker = Media.createTracker(config); // Use the instance for tracking media.
val config = mapOf(
MediaConstants.TrackerConfig.CHANNEL to "custom-channel",
MediaConstants.TrackerConfig.AD_PING_INTERVAL to 1,
MediaConstants.TrackerConfig.MAIN_PING_INTERVAL to 30,
)
val mediaTracker = Media.createTracker(config) // Use the instance for tracking media.
Creates an instance of the Media object.
Parameter | Description | Required |
---|---|---|
name |
The name of the media | Yes |
id |
The unqiue identifier for the media | Yes |
length |
The length of the media in seconds | Yes |
streamType |
Stream type | Yes |
mediaType |
Media type | Yes |
public static HashMap<String, Object> createMediaObject(String name,
String id,
int length,
String streamType,
MediaType mediaType);
HashMap<String, Object> mediaInfo = Media.createMediaObject("video-name",
"video-id",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video);
var mediaInfo = Media.createMediaObject("video-name",
"video-id",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video)
Creates an instance of the AdBreak object.
Parameter | Description | Required |
---|---|---|
name |
The friendly name of the Ad break such as pre-roll, mid-roll, or post-roll | Yes |
position |
The numeric position of the Ad break within the content, starting with 1 | Yes |
startTime |
The playhead value in seconds at the start of the ad break | Yes |
public static HashMap<String, Object> createAdBreakObject(String name, int position, int startTime);
HashMap<String, Object> adBreakObject = Media.createAdBreakObject("adbreak-name", 1, 0);
val adBreakObject = Media.createAdBreakObject("adbreak-name", 1, 0)
Creates an instance of the Ad object.
Parameter | Description | Required |
---|---|---|
name |
The friendly name of the Ad | Yes |
id |
The unique identifier for the Ad | Yes |
position |
The numeric position of the Ad within the ad break, starting with 1 | Yes |
length |
The length of Ad in seconds | Yes |
public static HashMap<String, Object> createAdObject(String name, String id, int position, int length);
HashMap<String, Object> adInfo = Media.createAdObject("ad-name", "ad-id", 1, 15);
val adInfo = Media.createAdObject("ad-name", "ad-id", 1, 15)
Creates an instance of the Chapter object.
Parameter | Description | Required |
---|---|---|
name |
The friendly name of the Chapter | Yes |
position |
The numeric position of the Chapter within the content, starting with 1 | Yes |
length |
The length of Chapter in seconds | Yes |
startTime |
The playhead value at the start of the chapter | Yes |
public static HashMap<String, Object> createChapterObject(String name,
int position,
int length,
int startTime);
HashMap<String, Object> chapterInfo = Media.createChapterObject("chapter-name", 1, 60, 0);
val chapterInfo = Media.createChapterObject("chapter-name", 1, 60, 0)
Creates an instance of the QoE object.
Parameter | Description | Required |
---|---|---|
bitrate |
The bitrate of media in bits per second | Yes |
startupTime |
The start up time of media in seconds | Yes |
fps |
The current frames per second information | Yes |
droppedFrames |
The number of dropped frames so far | Yes |
public static HashMap<String, Object> createQoEObject(int bitrate,
int startupTime,
int fps,
int droppedFrames);
HashMap<String, Object> qoeInfo = Media.createQoEObject(10000000, 2, 23, 10);
val qoeInfo = Media.createQoEObject(10000000, 2, 23, 10)
Creates an instance of the Player State object.
Parameter | Description | Required |
---|---|---|
name |
The player state name. Use Player State constants to track standard player states | Yes |
public static HashMap<String, Object> createStateObject(String stateName);
HashMap<String, Object> playerStateInfo = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);
val playerStateInfo = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)
Tracks the intention to start playback. This starts a tracking session on the media tracker instance. To learn how to resume a previously closed session.
Parameter | Description | Required |
---|---|---|
mediaInfo |
Media information created using the createMediaObject method. | Yes |
contextData |
Optional Media context data. For standard metadata keys, use standard video constants or standard audio constants. | No |
public void trackSessionStart(Map<String, Object> mediaInfo, Map<String, String> contextData);
HashMap<String, Object> mediaObject = Media.createMediaObject("media-name", "media-id", 60, MediaConstants.StreamType.VOD, Media.MediaType.Video);
HashMap<String, String> mediaMetadata = new HashMap<String, String>();
// Standard metadata keys provided by adobe.
mediaMetadata.put(MediaConstants.VideoMetadataKeys.EPISODE, "Sample Episode");
mediaMetadata.put(MediaConstants.VideoMetadataKeys.SHOW, "Sample Show");
// Custom metadata keys
mediaMetadata.put("isUserLoggedIn", "false");
mediaMetadata.put("tvStation", "Sample TV Station");
tracker.trackSessionStart(mediaInfo, mediaMetadata);
val mediaObject = Media.createMediaObject(
"media-name",
"media-id",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video
)
val mediaMetadata = mutableMapOf<String, String>()
// Standard metadata keys provided by adobe.
mediaMetadata[MediaConstants.VideoMetadataKeys.EPISODE] = "Sample Episode"
mediaMetadata[MediaConstants.VideoMetadataKeys.SHOW] = "Sample Show"
// Custom metadata keys
mediaMetadata["isUserLoggedIn"] = "false"
mediaMetadata["tvStation"] = "Sample TV Station"
tracker.trackSessionStart(mediaInfo, mediaMetadata)
Tracks the media play, or resume, after a previous pause.
public void trackPlay();
tracker.trackPlay();
tracker.trackPlay()
Tracks the media pause.
public void trackPause();
tracker.trackPause();
tracker.trackPause()
Tracks media complete. Call this method only when the media has been completely viewed.
public void trackComplete();
tracker.trackComplete();
tracker.trackComplete()
Tracks the end of a viewing session. Call this method even if the user does not view the media to completion.
public void trackSessionEnd();
tracker.trackSessionEnd();
tracker.trackSessionEnd()
Tracks an error in media playback.
Parameter | Description | Required |
---|---|---|
errorId |
Error Information | Yes |
public void trackError(String errorId);
tracker.trackError("errorId");
tracker.trackError("errorId")
Tracks media events.
Parameter | Description | Required |
---|---|---|
event |
The media event being tracked, use Media event constants | Yes |
info |
For an AdBreakStart event, the adBreak information is created by using the createAdBreakObject method. For an AdStart event, the Ad information is created by using the createAdObject method. For ChapterStart event, the Chapter information is created by using the createChapterObject method. For StateStart and StateEnd event, the State information is created by using the createStateObject method. |
Yes/No* |
data |
Optional context data can be provided for AdStart and ChapterStart events. This is not required for other events. |
No |
Note
* info is a required parameter forAdBreakStart
,AdStart
,ChapterStart
,StateStart
,StateEnd
events. Not set for any other event types.
public void trackEvent(Media.Event event, Map<String, Object> info, Map<String, String> data);
Tracking player States
// StateStart
HashMap<String, Object> stateObject = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);
tracker.trackEvent(Media.Event.StateStart, stateObject, null);
// StateEnd
HashMap<String, Object> stateObject = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);
tracker.trackEvent(Media.Event.StateEnd, stateObject, null);
// StateStart
val stateObject = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)
tracker.trackEvent(Media.Event.StateStart, stateObject, null)
// StateEnd
val stateObject = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)
tracker.trackEvent(Media.Event.StateEnd, stateObject, null)
Tracking ad breaks
// AdBreakStart
HashMap<String, Object> adBreakObject = Media.createAdBreakObject("adbreak-name", 1, 0);
tracker.trackEvent(Media.Event.AdBreakStart, adBreakObject, null);
// AdBreakComplete
tracker.trackEvent(Media.Event.AdBreakComplete, null, null);
// AdBreakStart
val adBreakObject = Media.createAdBreakObject("adbreak-name", 1, 0)
tracker.trackEvent(Media.Event.AdBreakStart, adBreakObject, null)
// AdBreakComplete
tracker.trackEvent(Media.Event.AdBreakComplete, null, null)
Tracking ads
// AdStart
HashMap<String, Object> adObject = Media.createAdObject("ad-name", "ad-id", 1, 15);
HashMap<String, String> adMetadata = new HashMap<String, String>();
// Standard metadata keys provided by adobe.
adMetadata.put(MediaConstants.AdMetadataKeys.ADVERTISER, "Sample Advertiser");
adMetadata.put(MediaConstants.AdMetadataKeys.CAMPAIGN_ID, "Sample Campaign");
// Custom metadata keys
adMetadata.put("affiliate", "Sample affiliate");
tracker.trackEvent(Media.Event.AdStart, adObject, adMetadata);
// AdComplete
tracker.trackEvent(Media.Event.AdComplete, null, null);
// AdSkip
tracker.trackEvent(Media.Event.AdSkip, null, null);
//AdStart
val adObject = Media.createAdObject("ad-name", "ad-id", 1, 15)
val adMetadata = mutableMapOf<String, String>()
// Standard metadata keys provided by adobe.
adMetadata[MediaConstants.AdMetadataKeys.ADVERTISER] = "Sample Advertiser"
adMetadata[MediaConstants.AdMetadataKeys.CAMPAIGN_ID] = "Sample Campaign"
// Custom metadata keys
adMetadata["affiliate"] = "Sample affiliate"
tracker.trackEvent(Media.Event.AdStart, adObject, adMetadata)
// AdComplete
tracker.trackEvent(Media.Event.AdComplete, null, null)
// AdSkip
tracker.trackEvent(Media.Event.AdSkip, null, null)
Tracking chapters
// ChapterStart
HashMap<String, Object> chapterObject = Media.createChapterObject("chapter-name", 1, 60, 0);
HashMap<String, String> chapterMetadata = new HashMap<String, String>();
chapterMetadata.put("segmentType", "Sample segment type");
tracker.trackEvent(Media.Event.ChapterStart, chapterObject, chapterMetadata);
// ChapterComplete
tracker.trackEvent(Media.Event.ChapterComplete, null, null);
// ChapterSkip
tracker.trackEvent(Media.Event.ChapterSkip, null, null);
// ChapterStart
val chapterObject = Media.createChapterObject("chapter-name", 1, 60, 0)
val chapterMetadata = HashMap<String, String>()
chapterMetadata["segmentType"] = "Sample segment type"
tracker.trackEvent(Media.Event.ChapterStart, chapterObject, chapterMetadata)
// ChapterComplete
tracker.trackEvent(Media.Event.ChapterComplete, null, null)
// ChapterSkip
tracker.trackEvent(Media.Event.ChapterSkip, null, null)
Tracking playback events
// BufferStart
tracker.trackEvent(Media.Event.BufferStart, null, null);
// BufferComplete
tracker.trackEvent(Media.Event.BufferComplete, null, null);
// SeekStart
tracker.trackEvent(Media.Event.SeekStart, null, null);
// SeekComplete
tracker.trackEvent(Media.Event.SeekComplete, null, null);
// BufferStart
tracker.trackEvent(Media.Event.BufferStart, null, null)
// BufferComplete
tracker.trackEvent(Media.Event.BufferComplete, null, null)
// SeekStart
tracker.trackEvent(Media.Event.SeekStart, null, null)
// SeekComplete
tracker.trackEvent(Media.Event.SeekComplete, null, null)
Tracking bitrate changes
// If the new bitrate value is available provide it to the tracker.
HashMap<String, Object> qoeObject = Media.createQoEObject(2000000, 2, 25, 10);
tracker.updateQoEObject(qoeObject);
// Bitrate change
tracker.trackEvent(Media.Event.BitrateChange, null, null);
// If the new bitrate value is available provide it to the tracker.
val qoeObject = Media.createQoEObject(2000000, 2, 25, 10)
tracker.updateQoEObject(qoeObject)
// Bitrate change
tracker.trackEvent(Media.Event.BitrateChange, null, null)
Provides the current media playhead to the media tracker instance. For accurate tracking, call this method everytime the playhead changes. If the player does not notify playhead changes, call this method once every second with the most recent playhead.
Parameter | Description |
---|---|
time |
Current playhead in seconds. For video-on-demand (VOD), the value is specified in seconds from the beginning of the media item. For live streaming, if the player does not provide information about the content duration, the value can be specified as the number of seconds since midnight UTC of that day. Note: When using progress markers, the content duration is required and the playhead needs to be updated as number of seconds from the beginning of the media item, starting with 0. |
public void updateCurrentPlayhead(int time);
tracker.updateCurrentPlayhead(1);
tracker.updateCurrentPlayhead(1)
}
Live streaming example
//Calculation for number of seconds since midnight UTC of the day
int timeFromMidnightInSecond = (int)((System.currentTimeMillis() / 1000) % 86400);
tracker.updateCurrentPlayhead(timeFromMidnightInSecond);
//Calculation for number of seconds since midnight UTC of the day
val timeFromMidnightInSecond = (System.currentTimeMillis() / 1000 % 86400).toInt()
tracker.updateCurrentPlayhead(timeFromMidnightInSecond);
Provides the media tracker with the current QoE information. For accurate tracking, call this method multiple times when the media player provides the updated QoE information.
Parameter | Description |
---|---|
qoeInfo |
Current QoE information that was created by using the createQoEObject method. |
public void updateQoEObject(Map<String, Object> qoeInfo);
HashMap<String, Object> qoeObject = Media.createQoEObject(1000000, 2, 25, 10);
tracker.updateQoEObject(qoeObject);
val qoeObject = Media.createQoEObject(1000000, 2, 25, 10)
tracker.updateQoEObject(qoeObject)
Refer MediaConstants.java to see the constants exposed by Media extension.