Edit in GitHubLog an issue

API reference

Edge Media API reference

extensionVersion

The extensionVersion() API returns the version of the Media for Edge Network extension that is registered with the Mobile Core extension.

Java

Syntax

Copied to your clipboard
public static String extensionVersion() {

Example

Copied to your clipboard
String mediaExtensionVersion = Media.extensionVersion();

Kotlin

Example

Copied to your clipboard
val mediaExtensionVersion = Media.extensionVersion()

resetIdentities

Immediately aborts all the active tracking sessions and clears all the MediaTracker instances.

See MobileCore.resetIdentities for more details.

createTracker

Creates a MediaTracker instance that should be used to track a playback session. The tracker sends periodic heartbeat pings to the Experience Edge Network.

Java

Syntax

Copied to your clipboard
public static MediaTracker createTracker()

Example

Copied to your clipboard
MediaTracker mediaTracker = Media.createTracker(); // Use the instance for tracking media.

Kotlin

Example

Copied to your clipboard
val tracker = Media.createTracker()

createTrackerWithConfig

Creates a MediaTracker instance that should be used to track a playback session. The tracker sends periodic heartbeat pings to the Experience Edge Network.

KeyDescriptionValueRequired
config.channel
The 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

Java

Syntax

Copied to your clipboard
public static MediaTracker createTracker(Map<String, Object> config)

Example

Copied to your clipboard
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.

Kotlin

Example

Copied to your clipboard
val config = mapOf(
MediaConstants.TrackerConfig.CHANNEL to "custom-channel",
MediaConstants.TrackerConfig.AD_PING_INTERVAL to 1,
MediaConstants.TrackerConfig.MAIN_PING_INTERVAL to 30,
)
val tracker = Media.createTracker(config) // Use the instance for tracking media.

createMediaObject

Creates an instance of the Media object which is a map/dictionary that contains information about the media.

ParameterDescriptionRequired
name
The friendly name of the media.
Yes
id
The unique identifier for the media.
Yes
length
The length of the media in seconds.
Yes
streamType
Yes
mediaType
Yes

Java

Syntax

Copied to your clipboard
public static HashMap<String, Object> createMediaObject(String name,
String id,
int length,
String streamType,
MediaType mediaType);

Example

Copied to your clipboard
HashMap<String, Object> mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video);

Kotlin

Example

Copied to your clipboard
var mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video)

createAdBreakObject

Creates an instance of the AdBreak object which is a map/dictionary that contains information about the ad break.

ParameterDescriptionRequired
name
The friendly name of ad break such as pre-roll, mid-roll, and 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

Java

Syntax

Copied to your clipboard
public static HashMap<String, Object> createAdBreakObject(String name, int position, int startTime);

Example

Copied to your clipboard
HashMap<String, Object> adBreakInfo = Media.createAdBreakObject("adbreakName", 1, 0);

Kotlin

Example

Copied to your clipboard
val adBreakInfo = Media.createAdBreakObject("adbreakName", 1, 0)

createAdObject

Creates an instance of the Ad object which is a map/dictionary that contains information about the Ad.

ParameterDescriptionRequired
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

Java

Syntax

Copied to your clipboard
public static HashMap<String, Object> createAdObject(String name, String id, int position, int length);

Example

Copied to your clipboard
HashMap<String, Object> adInfo = Media.createAdObject("adName", "adId", 1, 15);

Kotlin

Example

Copied to your clipboard
val adInfo = Media.createAdObject("adName", "adId", 1, 15)

createChapterObject

Creates an instance of the Chapter object which is a map/dictionary that contains information about the chapter.

ParameterDescriptionRequired
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

Java

Syntax

Copied to your clipboard
public static HashMap<String, Object> createChapterObject(String name,
int position,
int length,
int startTime);

Example

Copied to your clipboard
HashMap<String, Object> chapterInfo = Media.createChapterObject("chapterName", 1, 60, 0);

Kotlin

Example

Copied to your clipboard
val chapterInfo = Media.createChapterObject("chapterName", 1, 60, 0)

createQoEObject

Creates an instance of the QoE (Quality of Experience) object which is a map/dictionary that contains information about the quality of experience.

ParameterDescriptionRequired
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.
Yes
droppedFrames
The number of dropped frames so far.
Yes

Java

Syntax

Copied to your clipboard
public static HashMap<String, Object> createQoEObject(int bitrate,
int startupTime,
int fps,
int droppedFrames);

Example

Copied to your clipboard
HashMap<String, Object> qoeInfo = Media.createQoEObject(10000000, 2, 23, 10);

Kotlin

Example

Copied to your clipboard
val qoeInfo = Media.createQoEObject(10000000, 2, 23, 10)

createStateObject

Creates an instance of the Player State object which is a dictionary that contains information about the player state.

ParameterDescriptionRequired
name
The player state name. Use Player State constants to track standard player states.
Yes

Java

Syntax

Copied to your clipboard
public static HashMap<String, Object> createStateObject(String stateName);

Example

Copied to your clipboard
HashMap<String, Object> fullScreenState = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);

Kotlin

Example

Copied to your clipboard
val fullScreenState = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)

MediaTracker API reference

trackSessionStart

Tracks the intention to start playback. This starts a tracking session on the MediaTracker instance. To resume a previously closed session, see the media resume guide.

ParameterDescriptionRequired
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

Java

Syntax

Copied to your clipboard
public void trackSessionStart(Map<String, Object> mediaInfo, Map<String, String> contextData);

Example

Copied to your clipboard
HashMap<String, Object> mediaInfo = Media.createMediaObject("mediaName", "mediaId", 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);

Kotlin

Example

Copied to your clipboard
val mediaInfo = Media.createMediaObject(
"mediaName",
"mediaId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video
)
val mediaMetadata = mapOf<String, String>(
// Standard metadata keys provided by Adobe
MediaConstants.VideoMetadataKeys.EPISODE to "Sample Episode",
MediaConstants.VideoMetadataKeys.SHOW to "Sample Show",
// Custom metadata keys
"isUserLoggedIn" to "false",
"tvStation" to "Sample TV Station"
)
tracker.trackSessionStart(mediaInfo, mediaMetadata)

trackPlay

Tracks the media play, or resume, after a previous pause.

Java

Syntax

Copied to your clipboard
public void trackPlay();

Example

Copied to your clipboard
tracker.trackPlay();

Kotlin

Example

Copied to your clipboard
tracker.trackPlay()

trackPause

Tracks the media pause.

Java

Syntax

Copied to your clipboard
public void trackPause();

Example

Copied to your clipboard
tracker.trackPause();

Kotlin

Example

Copied to your clipboard
tracker.trackPause()

trackComplete

Tracks the completion of the media playback session. Call this method only when the media has been completely viewed. If the viewing session is ended before the media is completely viewed, use trackSessionEnd instead.

Java

Syntax

Copied to your clipboard
public void trackComplete();

Example

Copied to your clipboard
tracker.trackComplete();

Kotlin

Example

Copied to your clipboard
tracker.trackComplete()

trackSessionEnd

Tracks the end of a media playback session. Call this method when the viewing session ends, even if the user has not viewed the media to completion. If the media is viewed to completion, use trackComplete instead.

Java

Syntax

Copied to your clipboard
public void trackSessionEnd();

Example

Copied to your clipboard
tracker.trackSessionEnd();

Kotlin

Example

Copied to your clipboard
tracker.trackSessionEnd()

trackError

Tracks an error in media playback.

ParameterDescriptionRequired
errorId
The custom error Identifier.
Yes

Java

Syntax

Copied to your clipboard
public void trackError(String errorId);

Example

Copied to your clipboard
tracker.trackError("errorId");

Kotlin

Example

Copied to your clipboard
tracker.trackError("errorId")

trackEvent

Tracks media events.

ParameterDescriptionRequired
event
The media event being tracked, use Media event constants
Yes
info
For an AdBreakStart event, the AdBreak information is created by using the createAdBreakObjectWith method.
For an AdStart event, the Ad information is created by using the createAdObjectWith method.
For a ChapterStart event, the Chapter information is created by using the createChapterObjectWith method.
For a StateStart and StateEnd event, the State information is created by using the createStateObjectWith method.
Yes/No*
metadata
Optional context data can be provided for AdStart and ChapterStart events. This is not required for other events.
No

Java

Syntax

Copied to your clipboard
public void trackEvent(Media.Event event,
Map<String, Object> info,
Map<String, String> data);

Examples

Tracking player states

Copied to your clipboard
// StateStart
HashMap<String, Object> fullScreenState = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);
tracker.trackEvent(Media.Event.StateStart, fullScreenState, null);
// StateEnd
HashMap<String, Object> fullScreenState = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);
tracker.trackEvent(Media.Event.StateEnd, fullScreenState, null);

Tracking ad breaks

Copied to your clipboard
// AdBreakStart
HashMap<String, Object> adBreakInfo = Media.createAdBreakObject("adbreakName", 1, 0);
tracker.trackEvent(Media.Event.AdBreakStart, adBreakInfo, null);
// AdBreakComplete
tracker.trackEvent(Media.Event.AdBreakComplete, null, null);

Tracking ads

Copied to your clipboard
// AdStart
HashMap<String, Object> adInfo = Media.createAdObject("adName", "adId", 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, adInfo, adMetadata);
// AdComplete
tracker.trackEvent(Media.Event.AdComplete, null, null);
// AdSkip
tracker.trackEvent(Media.Event.AdSkip, null, null);

Tracking chapters

Copied to your clipboard
// ChapterStart
HashMap<String, Object> chapterInfo = Media.createChapterObject("chapterName", 1, 60, 0);
HashMap<String, String> chapterMetadata = new HashMap<String, String>();
chapterMetadata.put("segmentType", "Sample Segment type");
tracker.trackEvent(Media.Event.ChapterStart, chapterInfo, chapterMetadata);
// ChapterComplete
tracker.trackEvent(Media.Event.ChapterComplete, null, null);
// ChapterSkip
tracker.trackEvent(Media.Event.ChapterSkip, null, null);

Tracking playback events

Copied to your clipboard
// 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

Copied to your clipboard
// If the new bitrate value is available provide it to the tracker.
HashMap<String, Object> qoeInfo = Media.createQoEObject(2000000, 2, 25, 10);
tracker.updateQoEObject(qoeInfo);
// Bitrate change
tracker.trackEvent(Media.Event.BitrateChange, null, null);

Kotlin

Examples

Tracking player states

Copied to your clipboard
// StateStart
val stateInfo = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)
tracker.trackEvent(Media.Event.StateStart, stateInfo, null)
// StateEnd
val stateInfo = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)
tracker.trackEvent(Media.Event.StateEnd, stateInfo, null)

Tracking ad breaks

Copied to your clipboard
// AdBreakStart
val adBreakInfo = Media.createAdBreakObject("adbreakName", 1, 0)
tracker.trackEvent(Media.Event.AdBreakStart, adBreakInfo, null)
// AdBreakComplete
tracker.trackEvent(Media.Event.AdBreakComplete, null, null)

Tracking ads

Copied to your clipboard
//AdStart
val adInfo = Media.createAdObject("adName", "adId", 1, 15)
val adMetadata = mapOf<String, String>(
// Standard metadata keys provided by Adobe
MediaConstants.AdMetadataKeys.ADVERTISER to "Sample Advertiser",
MediaConstants.AdMetadataKeys.CAMPAIGN_ID to "Sample Campaign",
// Custom metadata keys
"affiliate" to "Sample Affiliate",
"tvStation" to "Sample TV Station"
)
tracker.trackEvent(Media.Event.AdStart, adInfo, adMetadata)
// AdComplete
tracker.trackEvent(Media.Event.AdComplete, null, null)
// AdSkip
tracker.trackEvent(Media.Event.AdSkip, null, null)

Tracking chapters

Copied to your clipboard
// ChapterStart
val chapterInfo = Media.createChapterObject("chapterName", 1L, 60, 0)
val chapterMetadata = mapOf<String, String>(
"segmentType" to "Sample Segment type"
)
tracker.trackEvent(Media.Event.ChapterStart, chapterInfo, chapterMetadata)
// ChapterComplete
tracker.trackEvent(Media.Event.ChapterComplete, null, null)
// ChapterSkip
tracker.trackEvent(Media.Event.ChapterSkip, null, null)

Tracking playback events

Copied to your clipboard
// 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

Copied to your clipboard
// If the new bitrate value is available provide it to the tracker.
val qoeInfo = Media.createQoEObject(2000000, 2, 25, 10)
tracker.updateQoEObject(qoeInfo)
// Bitrate change
tracker.trackEvent(Media.Event.BitrateChange, null, null)

updateCurrentPlayhead

Provides the current media playhead value to the MediaTracker instance. For accurate tracking, call this method every time the playhead value changes. If the player does not notify playhead value changes, call this method once every second with the most recent playhead value.

ParameterDescriptionRequired
time
Current playhead value 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.
Yes

Java

Syntax

Copied to your clipboard
public void updateCurrentPlayhead(int time);

Example

Copied to your clipboard
tracker.updateCurrentPlayhead(1);

Live streaming example

Copied to your clipboard
//Calculation for number of seconds since midnight UTC of the day
int timeFromMidnightInSecond = (int)((System.currentTimeMillis() / 1000) % 86400);
tracker.updateCurrentPlayhead(timeFromMidnightInSecond);

Kotlin

Example

Copied to your clipboard
tracker.updateCurrentPlayhead(1)

Live streaming example

Copied to your clipboard
val timeFromMidnightInSecond = ((System.currentTimeMillis() / 1000) % 86400).toInt()
tracker.updateCurrentPlayhead(timeFromMidnightInSecond)
}

updateQoEObject

Provides the MediaTracker with the current Quality of Experience (QoE) information. For accurate tracking, call this method every time the media player provides the updated QoE information.

ParameterDescription
qoeObject
Current QoE information that was created by using the createQoEObject method.

Java

Syntax

Copied to your clipboard
public void updateQoEObject(Map<String, Object> qoeInfo);

Example

Copied to your clipboard
HashMap<String, Object> qoeInfo = Media.createQoEObject(1000000, 2, 25, 10);
tracker.updateQoEObject(qoeInfo);

Kotlin

Example

Copied to your clipboard
val qoeInfo = Media.createQoEObject(1000000, 2, 25, 10)
tracker.updateQoEObject(qoeInfo)

Media constants

Media type

Defines the type of media that is currently being tracked. It can be either MediaType.Video or MediaType.Audio.

Copied to your clipboard
public class Media {
public enum MediaType {
/**
* Constant defining media type for Video streams
*/
Video,
/**
* Constant defining media type for Audio streams
*/
Audio
}
}

Example

Java

Copied to your clipboard
HashMap<String, Object> mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video)

Kotlin

Copied to your clipboard
val mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video)

Stream type

Defines the type of streamed content that is currently being tracked. Use the available constants or custom defined stream type values.

Copied to your clipboard
public class MediaConstants {
public static final class StreamType {
/**
* Constant defining stream type for VOD streams
*/
public static final String VOD = "vod";
/**
* Constant defining stream type for Live streams
*/
public static final String LIVE = "live";
/**
* Constant defining stream type for Linear streams
*/
public static final String LINEAR = "linear";
/**
* Constant defining stream type for Podcast streams
*/
public static final String PODCAST = "podcast";
/**
* Constant defining stream type for Audiobook streams
*/
public static final String AUDIOBOOK = "audiobook";
/**
* Constant defining stream type for AOD streams
*/
public static final String AOD = "aod";
}
}

Example

Java

Copied to your clipboard
HashMap<String, Object> mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video)

Kotlin

Copied to your clipboard
val mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video)

Standard video constants

Defines the standard video constants used as keys when creating or modifying video metadata dictionaries. Use the available constant values or custom defined video metadata key values.

Copied to your clipboard
public class MediaConstants {
public static final class VideoMetadataKeys {
public static final String AD_LOAD = "adLoad";
public static final String ASSET_ID = "assetID";
public static final String AUTHORIZED = "isAuthenticated";
public static final String DAY_PART = "dayPart";
public static final String EPISODE = "episode";
public static final String FEED = "feed";
public static final String FIRST_AIR_DATE = "firstAirDate";
public static final String FIRST_DIGITAL_DATE = "firstDigitalDate";
public static final String GENRE = "genre";
public static final String MVPD = "mvpd";
public static final String NETWORK = "network";
public static final String ORIGINATOR = "originator";
public static final String SEASON = "season";
public static final String SHOW = "show";
public static final String SHOW_TYPE = "showType";
public static final String STREAM_FORMAT = "streamFormat";
public static final String RATING = "rating";
}
}

Example

Java

Copied to your clipboard
HashMap<String, Object> mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video)
HashMap<String, String> videoMetadata = new HashMap<String, String>();
// Standard Video Metadata
videoMetadata.put(MediaConstants.VideoMetadataKeys.SHOW, "Sample Show");
videoMetadata.put(MediaConstants.VideoMetadataKeys.SEASON, "Sample Season");
tracker.trackSessionStart(mediaInfo, videoMetadata);

Kotlin

Copied to your clipboard
val mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.VOD,
Media.MediaType.Video)
val videoMetadata = mutableMapOf(MediaConstants.VideoMetadataKeys.SHOW to "Sample Show",
MediaConstants.VideoMetadataKeys.SEASON to "Sample Season")
tracker.trackSessionStart(mediaInfo, videoMetadata)

Standard audio constants

Defines the standard audio constants used as keys when creating or modifying audio metadata dictionaries. Use the available constant values or custom defined audio metadata key values.

Copied to your clipboard
public class MediaConstants {
public static final class AudioMetadataKeys {
public static final String ALBUM = "album";
public static final String ARTIST = "artist";
public static final String AUTHOR = "author";
public static final String LABEL = "label";
public static final String PUBLISHER = "publisher";
public static final String STATION = "station";
}
}

Example

Java

Copied to your clipboard
HashMap<String, Object> mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.AOD,
Media.MediaType.Audio)
HashMap<String, String> audioMetadata = new HashMap<String, String>();
// Standard Video Metadata
audioMetadata.put(MediaConstants.AudioMetadataKeys.ARTIST, "Sample Artist");
audioMetadata.put(MediaConstants.AudioMetadataKeys.ALBUM, "Sample Album");
tracker.trackSessionStart(mediaInfo, audioMetadata);

Kotlin

Copied to your clipboard
val mediaInfo = Media.createMediaObject("videoName",
"videoId",
60,
MediaConstants.StreamType.AOD,
Media.MediaType.Audio)
val audioMetadata = mutableMapOf(MediaConstants.AudioMetadataKeys.ARTIST to "Sample Artist",
MediaConstants.AudioMetadataKeys.ALBUM to "Sample Album")
tracker.trackSessionStart(mediaInfo, audioMetadata)

Standard ad constants

Defines the standard metadata keys for ads.

Copied to your clipboard
public class MediaConstants {
public static final class AdMetadataKeys {
public static final String ADVERTISER = "advertiser";
public static final String CAMPAIGN_ID = "campaignID";
public static final String CREATIVE_ID = "creativeID";
public static final String CREATIVE_URL = "creativeURL";
public static final String PLACEMENT_ID = "placementID";
public static final String SITE_ID = "siteID";
}
}

Example

Java

Copied to your clipboard
HashMap<String, Object> adInfo = Media.createAdObject("adName", "adId", 1, 15);
HashMap<String, String> adMetadata = new HashMap<String, String>();
// Standard Video Metadata
adMetadata.put(MediaConstants.AdMetadataKeys.ADVERTISER, "Sample Advertiser");
adMetadata.put(MediaConstants.AdMetadataKeys.CAMPAIGN_ID, "Sample Campaign");
tracker.trackEvent(Media.Event.AdStart, adInfo, adMetadata);

Kotlin

Copied to your clipboard
val adInfo = Media.createAdObject("adName", "adId", 1, 15)
val adMetadata = mutableMapOf(MediaConstants.AdMetadataKeys.ADVERTISER to "Sample Advertiser",
MediaConstants.AdMetadataKeys.CAMPAIGN_ID to "Sample Campaign")
tracker.trackEvent(Media.Event.AdStart, adInfo, adMetadata)

Player state constants

Defines the state of the media player that is currently being tracked. Use the available constant values or custom defined player state values.

Copied to your clipboard
public class MediaConstants {
public static final class PlayerState {
public static final String FULLSCREEN = "fullscreen";
public static final String PICTURE_IN_PICTURE = "pictureInPicture";
public static final String CLOSED_CAPTION = "closeCaption";
public static final String IN_FOCUS = "inFocus";
public static final String MUTE = "mute";
}
}

Example

Java

Copied to your clipboard
HashMap<String, Object> fullScreenState = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);

Kotlin

Copied to your clipboard
val fullScreenState = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)

Media events

Defines the media event that is currently being tracked. Only the available constant values are allowed.

Copied to your clipboard
public class Media {
/**
* These enumeration values define the type of a tracking event
*/
public enum Event {
/**
* Constant defining event type for AdBreak start
*/
AdBreakStart,
/**
* Constant defining event type for AdBreak complete
*/
AdBreakComplete,
/**
* Constant defining event type for Ad start
*/
AdStart,
/**
* Constant defining event type for Ad complete
*/
AdComplete,
/**
* Constant defining event type for Ad skip
*/
AdSkip,
/**
* Constant defining event type for Chapter start
*/
ChapterStart,
/**
* Constant defining event type for Chapter complete
*/
ChapterComplete,
/**
* Constant defining event type for Chapter skip
*/
ChapterSkip,
/**
* Constant defining event type for Seek start
*/
SeekStart,
/**
* Constant defining event type for Seek complete
*/
SeekComplete,
/**
* Constant defining event type for Buffer start
*/
BufferStart,
/**
* Constant defining event type for Buffer complete
*/
BufferComplete,
/**
* Constant defining event type for change in Bitrate
*/
BitrateChange,
/**
* Constant defining event type for State start
*/
StateStart,
/**
* Constant defining event type for State end
*/
StateEnd
}
}

Examples

Java

Copied to your clipboard
tracker.trackEvent(Media.Event.BitrateChange, null, null);

Kotlin

Copied to your clipboard
tracker.trackEvent(Media.Event.BitrateChange, null, null)

Media resume

Constant to denote that the current tracking session is resuming a previously closed session. This information must be provided when starting a tracking session.

Java

Syntax

Copied to your clipboard
public class MediaConstants {
public static final class MediaObjectKey {
/**
* Constant defining explicit media resumed property. Set this to true on MediaObject if resuming a previously closed session.
*/
public static final String RESUMED;
}
}

Example

Java

Copied to your clipboard
HashMap<String, Object> mediaInfo = Media.createMediaObject("mediaName", "mediaId", 60, MediaConstants.StreamType.VOD, Media.MediaType.Video);
// Attach media resumed information.
mediaInfo.put(MediaConstants.MediaObjectKey.RESUMED, true);
tracker.trackSessionStart(mediaInfo, null);

Kotlin

Copied to your clipboard
val mediaInfo = Media.createMediaObject("mediaName", "mediaId", 60, MediaConstants.StreamType.VOD, Media.MediaType.Video)
// Attach media resumed information.
mediaInfo[MediaConstants.MediaObjectKey.RESUMED] = true
tracker.trackSessionStart(mediaInfo, null)
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.