Media API reference

extensionVersion

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

To get the version of the Media extension, use the following code sample:

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

Java

String mediaExtensionVersion = Media.extensionVersion();
iOS (AEP 3.x)

Swift

let mediaExtensionVersion = Media.extensionVersion()

Objective-C

NSString *mediaExtensionVersion = [AEPMobileMedia extensionVersion];
iOS (ACP 2.x)

Objective-C

NSString *mediaExtensionVersion = [ACPMedia extensionVersion];

Swift

let mediaExtensionVersion = ACPMedia.extensionVersion()
React Native

JavaScript

ACPMedia.extensionVersion().then(mediaExtensionVersion => console.log("AdobeExperienceSDK: ACPMedia version: " + mediaExtensionVersion));

createTracker

The API createTracker with callback has been deprecated for the synchronous version

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.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

createTracker

The createTracker function returns the instance of MediaTracker for tracking a media session. The createTracker function with callback as a parameter has been deprecated.

If MobileCore.resetIdentities() is called in the implementation, the existing tracker will stop sending pings. You will need to create a new tracker to generate a new media session.

Syntax

public static MediaTracker createTracker()
// Deprecated
public static void createTracker(AdobeCallback<MediaTracker> callback)

Example

MediaTracker mediaTracker = Media.createTracker(); // Use the instance for tracking media.
// Deprecated
Media.createTracker(new AdobeCallback<MediaTracker>() {
@Override
public void call(MediaTracker mediaTracker) {
// Use the instance for tracking media.
}
});
iOS (AEP 3.x)

createTracker

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.

If MobileCore.resetIdentities() is called in the implementation, the existing tracker will stop sending pings. You will need to create a new tracker to generate a new media session.

Syntax

static func createTracker()

Examples

Swift

let tracker = Media.createTracker() // Use the instance for tracking media.

Objective-C

id<AEPMediaTracker> tracker;
_tracker = [AEPMobileMedia createTracker]; // Use the instance for tracking media.
iOS (ACP 2.x)

createTracker

The createTracker function returns the instance of ACPMediaTracker for tracking a media session. The createTracker function with callback as a parameter has been deprecated.

Syntax

+(ACPMediaTracker* _Nullable) createTracker;
// Deprecated
+(void) createTracker: (void (^ _Nonnull) (ACPMediaTracker* _Nullable)) callback;

Examples

Here are examples in Objective-C and Swift:

Objective-C

ACPMediaTracker *mediaTracker = [ACPMedia createTracker]; // Use the instance for tracking media.
// Deprecated
[ACPMedia createTracker:^(ACPMediaTracker * _Nullable mediaTracker) {
// Use the instance for tracking media.
}];

Swift

let mediaTracker = ACPMedia.createTracker() // Use the instance for tracking media.
// Deprecated
ACPMedia.createTracker({mediaTracker in
// Use the instance for tracking media.
})
React Native

JavaScript

createTracker

ACPMedia.createTracker().then(tracker =>
this.setState({currentTracker: tracker})
);

createTrackerWithConfig

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 from launch for media tracked with this tracker instance.

String

No

config.downloadedcontent

Creates a tracker instance to track downloaded media. Instead of sending periodic pings, the tracker only sends one ping for the entire content.

Boolean

No

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

createTracker

Optional configuration about the tracker can be passed to this function. The createTracker function returns the instance of MediaTracker with the configuration for tracking a media session. The createTracker function with callback as a parameter has been deprecated.

Syntax

public class MediaConstants {
public static final class Config {
public static final String CHANNEL = "config.channel";
public static final String DOWNLOADED_CONTENT = "config.downloadedcontent";
}
}
public static MediaTracker createTracker(Map<String, Object> config)
// Deprecated
public static void createTracker(Map<String, Object> config, final AdobeCallback<MediaTracker> callback)

Example

HashMap<String, Object> config = new HashMap<String, Object>();
config.put(MediaConstants.Config.CHANNEL, "custom-channel"); // Override channel configured from launch
config.put(MediaConstants.Config.DOWNLOADED_CONTENT, true); // Creates downloaded content tracker
MediaTracker mediaTracker = Media.createTracker(config); // Use the instance for tracking media.
// Deprecated
Media.createTracker(config, new AdobeCallback<MediaTracker>() {
@Override
public void call(MediaTracker mediaTracker) {
// Use the instance for tracking media.
}
});
iOS (AEP 3.x)

createTrackerWithConfig

Creates a media tracker instance based on the configuration to track the playback session.

Syntax

static func createTrackerWith(config: [String: Any]?)

Examples

Swift

var config: [String: Any] = [:]
config[MediaConstants.TrackerConfig.CHANNEL] = "custom-channel" // Overrides channel configured from launch
config[MediaConstants.TrackerConfig.DOWNLOADED_CONTENT] = true // Creates downloaded content tracker
let tracker = Media.createTrackerWith(config: config)

Objective-C

id<AEPMediaTracker> _tracker;
NSMutableDictionary* config = [NSMutableDictionary dictionary];
config[AEPMediaTrackerConfig.CHANNEL] = @"custom-channel"; // Overrides channel configured from launch
config[AEPMediaTrackerConfig.DOWNLOADED_CONTENT] = [NSNumber numberWithBool:true]; // Creates downloaded content tracker
_tracker = [AEPMobileMedia createTrackerWithConfig:config];
iOS (ACP 2.x)

createTrackerWithConfig

Optional configuration about the tracker can be passed to this function. The createTracker function returns the instance of ACPMediaTracker with the configuration for tracking a media session. The createTracker function with callback as a parameter has been deprecated.

Syntax

FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaKeyConfigChannel;
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaKeyConfigDownloadedContent;
+ (ACPMediaTracker* _Nullable) createTrackerWithConfig: (NSDictionary* _Nullable) config;
// Deprecated
+ (void) createTrackerWithConfig: (NSDictionary* _Nullable) config
callback: (void (^ _Nonnull) (ACPMediaTracker* _Nullable)) callback;

Examples

Here are examples in Objective-C and Swift:

Objective-C

NSMutableDictionary* config = [NSMutableDictionary dictionary];
config[ACPMediaKeyConfigChannel] = @"custom-channel"; // Override channel configured from launch
config[ACPMediaKeyConfigDownloadedContent] = @YES; // Creates downloaded content tracker
ACPMediaTracker *mediaTracker = [ACPMedia createTrackerWithConfig:config]; // Use the instance for tracking media.
// Deprecated
[ACPMedia createTrackerWithConfig: config
callback:^(ACPMediaTracker * _Nullable mediaTracker) {
// Use the instance for tracking media.
}];

Swift

var config: [String: Any] = [:]
config[ACPMediaKeyConfigChannel] = "custom-channel" // Override channel configured from launch
config[ACPMediaKeyConfigDownloadedContent] = true // Creates downloaded content tracker
let mediaTracker = ACPMedia.createTrackerWithConfig(config); // Use the instance for tracking media.
// Deprecated
ACPMedia.createTrackerWithConfig(config, {mediaTracker in
// Use the instance for tracking media.
}
React Native

JavaScript

createTracker

var config = new Object();
config[ACPMediaConstants.ACPMediaKeyConfigChannel] = "customer-channel"; // Override channel configured from launch
config[ACPMediaConstants.ACPMediaKeyConfigDownloadedContent] = true; // Creates downloaded content tracker
ACPMedia.createTrackerWithConfig(config).then(tracker =>
this.setState({currentTracker: tracker})
);

createMediaObject

Creates an instance of the Media object.

Variable Name

Description

Required

name

Media name

Yes

mediaId

Media unique identifier

Yes

length

Media length

Yes

streamType

Stream type

Yes

mediaType

Media type

Yes

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

createMediaObject

Returns a HashMap instance that contains information about the media.

Syntax

public static HashMap<String, Object> createMediaObject(String name,
String mediaId,
Double length,
String streamType,
MediaType mediaType);

Example

HashMap<String, Object> mediaInfo = Media.createMediaObject("video-name",
"video-id",
60D,
MediaConstants.StreamType.VOD,
Media.MediaType.Video);
iOS (AEP 3.x)

createMediaObject

Returns a map that contains information about the media.

Syntax

static func createMediaObjectWith(name: String,
id: String,
length: Double,
streamType: String,
mediaType: MediaType) -> [String: Any]?

Example

Swift

let mediaObject = Media.createMediaObjectWith(name: "video-name",
id: "videoId",
length: 60,
streamType: MediaConstants.StreamType.VOD,
mediaType: MediaType.Video)

Objective-C

NSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name"
id:@"video-id"
length:60
streamType:AEPMediaStreamType.VOD
mediaType:AEPMediaTypeVideo];
iOS (ACP 2.x)

createMediaObjectWithName

Returns an NSDictionary instance that contains information about the media.

Syntax

+ (NSDictionary* _Nonnull) createMediaObjectWithName: (NSString* _Nonnull) name
mediaId: (NSString* _Nonnull) mediaId
length: (double) length
streamType: (NSString* _Nonnull) streamType
mediaType: (ACPMediaType) mediaType;

Example

Here are examples in Objective-C and Swift:

Objective-C

NSDictionary *mediaObject = [ACPMedia createMediaObjectWithName: @"video-name"
mediaId: @"video-id"
length: 60
streamType: ACPMediaStreamTypeVod
mediaType: ACPMediaTypeVideo];

Swift

let mediaObject = ACPMedia.createMediaObject(withName: "video-name", mediaId: "video-id",
length: Double(60),
streamType: ACPMediaStreamTypeVod,
mediaType:ACPMediaType.video)
React Native

JavaScript

createMediaObject

let mediaObject = ACPMedia.createMediaObject("video-name", "video-id", 60, ACPMediaConstants.ACPMediaStreamTypeVod, ACPMediaType.Video);

createAdBreakObject

Creates an instance of the AdBreak object.

Variable Name

Description

Required

name

Ad break name such as pre-roll, mid-roll, and post-roll.

Yes

position

The number position of the ad break within the content, starting with 1.

Yes

startTime

Playhead value at the start of the ad break.

Yes

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

createAdBreakObject

Returns a HashMap instance that contains information about the ad break.

Syntax

public static HashMap<String, Object> createAdBreakObject(String name, Long position, Double startTime);

Example

HashMap<String, Object> adBreakObject = Media.createAdBreakObject("adbreak-name", 1L, 0D);
iOS (AEP 3.x)

createAdBreakObject

Returns a map that contains information about the ad break.

Syntax

static func createAdBreakObjectWith(name: String,
position: Int,
startTime: Double) -> [String: Any]?

Example

Swift

let adBreakObject = Media.createAdBreakObjectWith(name: "adbreak-name",
position: 1,
startTime: 0)

Objective-C

NSDictionary *adBreakObject = [AEPMobileMedia createAdBreakObjectWith:@"adbreak-name"
position:1
startTime:0];
iOS (ACP 2.x)

createAdBreakObjectWithName

Returns an NSDictionary instance that contains information about the ad break.

Syntax

+ (NSDictionary* _Nonnull) createAdBreakObjectWithName: (NSString* _Nonnull) name
position: (double) position
startTime: (double) startTime;

Example

Here are examples in Objective-C and Swift:

Objective-C

NSDictionary *adBreakObject = [ACPMedia createAdBreakObjectWithName: @"adbreak-name"
position: 1
startTime: 0];

Swift

let adBreakObject = ACPMedia.createAdBreakObject(withName: "adbreak-name", position: 1, startTime: 0)
React Native

JavaScript

createAdBreakObject

let adBreakObject = ACPMedia.createAdBreakObject("adbreak-name", 1, 0);

createAdObject

Creates an instance of the Ad object.

Variable Name

Description

Required

name

Friendly name of the ad.

Yes

adId

Unique identifier for the ad.

Yes

position

The number position of the ad within the ad break, starting with 1.

Yes

length

Ad length

Yes

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

createAdObject

Returns a HashMap instance that contains information about the ad.

Syntax

public static HashMap<String, Object> createAdObject(String name, String adId, Long position, Double length);

Example

HashMap<String, Object> adInfo = Media.createAdObject("ad-name", "ad-id", 1L, 15D);
iOS (AEP 3.x)

createAdObject

Returns a map that contains information about the ad.

Syntax

static func createAdObjectWith(name: String,
id: String,
position: Int,
length: Double) -> [String: Any]?

Example

Swift

let adObject = Media.createObjectWith(name: "ad-name",
id: "ad-id",
position: 0,
length: 30)

Objective-C

NSDictionary *adObject = [AEPMobileMedia createAdObjectWith:@"ad-name"
id:@"ad-id"
position:0
length:30];
iOS (ACP 2.x)

createAdObjectWithName

Returns an NSDictionary instance that contains information about the ad.

Syntax

+ (NSDictionary* _Nonnull) createAdObjectWithName: (NSString* _Nonnull) name
adId: (NSString* _Nonnull) adId
position: (double) position
length: (double) length;

Example

Here are examples in Objective-C and Swift:

Objective-C

NSDictionary *adObject = [ACPMedia createAdObjectWithName: @"ad-name"
adId: @"ad-id"
position: 1
length: 15];

Swift

let adObject = ACPMedia.createAdObject(withName: "ad-name", adId: "ad-id", position: 1, length: 15)
React Native

JavaScript

createAdObject

let adObject = ACPMedia.createAdObject("ad-name", "ad-id", 1, 15);

createChapterObject

Creates an instance of the Chapter object.

Variable Name

Description

Required

name

Chapter name

Yes

position

The number position of the chapter within the content, starting with 1.

Yes

length

Chapter length

Yes

startTime

Playhead value at the start of the chapter

Yes

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

createChapterObject

Returns a HashMap instance that contains information about the chapter.

Syntax

public static HashMap<String, Object> createChapterObject(String name,
Long position,
Double length,
Double startTime);

Example

HashMap<String, Object> chapterInfo = Media.createChapterObject("chapter-name", 1L, 60D, 0D);
iOS (AEP 3.x)

createChapterObject

Returns a map that contains information about the chapter.

Syntax

static func createChapterObjectWith(name: String,
position: Int,
length: Double,
startTime: Double) -> [String: Any]?

Example

Swift

let chapterObject = Media.createChapterObjectWith(name: "chapter_name",
position: 1,
length: 60,
startTime: 0)

Objective-C

NSDictionary *chapterObject = [AEPMobileMedia createChapterObjectWith:@"chapter_name"
position:1
length:60
startTime:0];
iOS (ACP 2.x)

createChapterObjectWithName

Returns an NSDictionary instance that contains information about the chapter.

Syntax

+ (NSDictionary* _Nonnull) createChapterObjectWithName: (NSString* _Nonnull) name
position: (double) position
length: (double) length
startTime: (double) startTime;

Example

Here are examples in Objective-C and Swift:

Objective-C

NSDictionary *chapterObject = [ACPMedia createChapterObjectWithName: @"chapter-name"
position: 1
length: 60
startTime: 0];

Swift

let chapterObject = ACPMedia.createChapterObject(withName: "chapter-name", position: 1, length: 60, startTime: 0)
React Native

JavaScript

createChapterObject

let chapterObject = ACPMedia.createChapterObject('chapter-name', 1, 60, 0);

createQoEObject

Creates an instance of the QoE object.

Variable Name

Description

Required

bitrate

Current bitrate

Yes

startupTime

Startup time

Yes

fps

FPS value

Yes

droppedFrames

Number of dropped frames

Yes

All the QoE values bitrate, startupTime, fps, droppedFrames would be converted to long for reporting purposes.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

createQoEObject

Returns a HashMap instance that contains information about the quality of experience.

Syntax

public static HashMap<String, Object> createQoEObject(Long bitrate,
Double startupTime,
Double fps,
Long droppedFrames);

Example

HashMap<String, Object> qoeInfo = Media.createQoEObject(10000000L, 2D, 23D, 10D);
iOS (AEP 3.x)

createQoEObject

Returns a map that contains information about the quality of experience.

Syntax

static func createQoEObjectWith(bitrate: Double,
startupTime: Double,
fps: Double,
droppedFrames: Double) -> [String: Any]?

Example

Swift

let qoeObject = Media.createQoEObjectWith(bitrate: 500000,
startupTime: 2,
fps: 24,
droppedFrames: 10)

Objective-C

NSDictionary *qoeObject = [AEPMobileMedia createQoEObjectWith:50000
startTime:2
fps:24
droppedFrames:10];
iOS (ACP 2.x)

createQoEObjectWithBitrate

Returns an NSDictionary instance that contains information about the quality of experience.

Syntax

+ (NSDictionary* _Nonnull) createQoEObjectWithBitrate: (double) bitrate
startupTime: (double) startupTime
fps: (double) fps
droppedFrames: (double) droppedFrames;

Example

Here are examples in Objective-C and Swift:

Objective-C

NSDictionary *qoeObject = [ACPMedia createQoEObjectWithBitrate: 10000000
startupTime: 2
fps: 23
droppedFrames: 10];

Swift

let qoeObject = ACPMedia.createQoEObject(withBitrate: 10000000, startupTime: 2, fps: 23, droppedFrames: 10)
React Native

JavaScript

createQoEObject

let qoeObject = ACPMedia.createQoEObject(1000000, 2, 23, 10);

createStateObject

Creates an instance of the Player State object.

Variable Name

Description

Required

name

State name(Use Player State constants to track standard player states)

Yes

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

createStateObject

Returns a HashMap instance that contains information about the State.

Syntax

public static HashMap<String, Object> createStateObject(String stateName);

Example

HashMap<String, Object> playerStateInfo = Media.createStateObject("fullscreen");
iOS (AEP 3.x)

createStateObject

Returns a map that contains information about the player state.

Syntax

static func createStateObjectWith(stateName: String) -> [String: Any]

Example

Swift

let fullScreenState = Media.createStateObjectWith(stateName: "fullscreen")

Objective-C

NSDictionary* fullScreenState = [AEPMobileMedia createStateObjectWith:AEPMediaPlayerState.FULLSCREEN]
iOS (ACP 2.x)

createStateObjectWithName

Returns an NSDictionary instance that contains information about the player state.

Syntax

+ (NSDictionary* _Nonnull) createStateObjectWithName: (NSString* _Nonnull) stateName;

Example

Here are examples in Objective-C and Swift:

Objective-C

NSDictionary *playerStateObject = [ACPMedia createStateObjectWithName: @"fullscreen"];

Swift

let playerStateObject = ACPMedia.createStateObject(withName: "fullscreen")
React Native

JavaScript

createStateObject

let playerStateObject = ACPMedia.createStateObject("fullscreen");

Media tracker API reference

trackSessionStart

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, please read the media resume guide

Variable Name

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

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

trackSessionStart

Syntax

public void trackSessionStart(Map<String, Object> mediaInfo, Map<String, String> contextData);

Example

HashMap<String, Object> mediaObject = Media.createMediaObject("media-name", "media-id", 60D, 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);
iOS (AEP 3.x)

trackSessionStart

Syntax

public func trackSessionStart(info: [String: Any], metadata: [String: String]? = nil)

Example

Swift

let mediaObject = Media.createMediaObjectWith(name: "video-name", id: "videoId", length: 60, streamType: MediaConstants.StreamType.VOD, mediaType: MediaType.Video)
var videoMetadata: [String: String] = [:]
// Sample implementation for using video standard metadata keys
videoMetadata[MediaConstants.VideoMetadataKeys.SHOW] = "Sample show"
videoMetadata[MediaConstants.VideoMetadataKeys.SEASON] = "Sample season"
// Sample implementation for using custom metadata keys
videoMetadata["isUserLoggedIn"] = "false"
videoMetadata["tvStation"] = "Sample TV station"
tracker.trackSessionStart(info: mediaObject, metadata: videoMetadata)

Objective-C

NSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name" id:@"video-id" length:60 streamType:AEPMediaStreamType.VOD mediaType:AEPMediaTypeVideo];
NSMutableDictionary *videoMetadata = [[NSMutableDictionary alloc] init];
// Sample implementation for using standard video metadata keys
[videoMetadata setObject:@"Sample show" forKey:AEPVideoMetadataKeys.SHOW];
[videoMetadata setObject:@"Sample Season" forKey:AEPVideoMetadataKeys.SEASON];
// Sample implementation for using custom metadata keys
[videoMetadata setObject:@"false" forKey:@"isUserLoggedIn"];
[videoMetadata setObject:@"Sample TV station" forKey:@"tvStation"];
[_tracker trackSessionStart:mediaObject metadata:videoMetadata];
iOS (ACP 2.x)

trackSessionStart

Syntax

- (void) trackSessionStart: (NSDictionary* _Nonnull) mediaInfo data: (NSDictionary* _Nullable) contextData;

Example

Here are examples in Objective-C and Swift:

Objective-C

NSDictionary *mediaObject = [ACPMedia createMediaObjectWithName:@"media-name" mediaId:@"media-id" length:60 streamType:ACPMediaStreamTypeVod mediaType:ACPMediaTypeVideo];
NSMutableDictionary *mediaMetadata = [[NSMutableDictionary alloc] init];
// Standard metadata keys provided by adobe.
[mediaMetadata setObject:@"Sample show" forKey:ACPVideoMetadataKeyShow];
[mediaMetadata setObject:@"Sample season" forKey:ACPVideoMetadataKeySeason];
// Custom metadata keys
[mediaMetadata setObject:@"false" forKey:@"isUserLoggedIn"];
[mediaMetadata setObject:@"Sample TV station" forKey:@"tvStation"];
[_tracker trackSessionStart:mediaObject data:mediaMetadata];

Swift

let mediaObject = ACPMedia.createMediaObject(withName: "media-name", mediaId: "media-id", length: 60, streamType: ACPMediaStreamTypeVod, mediaType:ACPMediaType.video)
// Standard metadata keys provided by adobe.
var mediaMetadata = [ACPVideoMetadataKeyShow: "Sample show", ACPVideoMetadataKeySeason: "Sample season"]
// Custom metadata keys
mediaMetadata["isUserLoggedIn"] = "false"
mediaMetadata["tvStation"] = "Sample TV station"
_tracker.trackSessionStart(mediaObject, data: mediaMetadata)
React Native

JavaScript

trackSessionStart

let mediaObject = ACPMedia.createMediaObject("media-name", "media-id", 60, ACPMediaConstants.ACPMediaStreamTypeVod, ACPMediaType.Video);
var mediaMetadata = new Object();
mediaMetadata[ACPMediaConstants.ACPVideoMetadataKeyShow] = "Sample Show";
mediaMetadata[ACPMediaConstants.ACPVideoMetadataKeySeason] = "Sample Season";
// Custom metadata keys
mediaMetadata["isUserLoggedIn"] = "false";
mediaMetadata["tvStation"] = "Sample TV station";
tracker.trackSessionStart(mediaObject, mediaMetadata);

trackPlay

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

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

trackPlay

Syntax

public void trackPlay();

Example

_tracker.trackPlay();
iOS (AEP 3.x)

trackPlay

Syntax

func trackPlay()

Example

Swift

tracker.trackPlay()

Objective-C

[_tracker trackPlay];
iOS (ACP 2.x)

trackPlay

Syntax

- (void) trackPlay;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackPlay];

Swift

_tracker.trackPlay()
React Native

JavaScript

trackPlay

tracker.trackPlay();

trackPause

Tracks the media pause.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

trackPause

Syntax

public void trackPause();

Example

_tracker.trackPause();
iOS (AEP 3.x)

trackPause

Syntax

func trackPause()

Example

Swift

tracker.trackPause()

Objective-C

[_tracker trackPause];
iOS (ACP 2.x)

trackPause

Syntax

- (void) trackPause;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackPause];

Swift

_tracker.trackPause()
React Native

JavaScript

trackPause

tracker.trackPause();

trackComplete

Tracks media complete. Call this method only when the media has been completely viewed.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

trackComplete

Syntax

public void trackComplete();

Example

_tracker.trackComplete();
iOS (AEP 3.x)

trackComplete

Syntax

func trackComplete()

Example

Swift

tracker.trackComplete()

Objective-C

[_tracker trackComplete];
iOS (ACP 2.x)

trackComplete

Syntax

- (void) trackComplete;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackComplete];

Swift

_tracker.trackComplete()
React Native

JavaScript

trackComplete

tracker.trackComplete();

trackSessionEnd

Tracks the end of a viewing session. Call this method even if the user does not view the media to completion.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

trackSessionEnd

Syntax

public void trackSessionEnd();

Example

_tracker.trackSessionEnd();
iOS (AEP 3.x)

trackSessionEnd

Syntax

func trackSessionEnd()

Example

Here are examples in Objective-C and Swift:

Swift

tracker.trackSessionEnd()

Objective-C

[_tracker trackSessionEnd];
iOS (ACP 2.x)

trackSessionEnd

Syntax

- (void) trackSessionEnd;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackSessionEnd];

Swift

_tracker.trackSessionEnd()
React Native

JavaScript

trackSessionEnd

tracker.trackSessionEnd();

trackError

Tracks an error in media playback.

Variable Name

Description

Required

errorId

Error Information

Yes

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

trackError

Syntax

public void trackError(String errorId);

Example

_tracker.trackError("errorId");
iOS (AEP 3.x)

trackError

Syntax

func trackError(errorId: String)

Example

Swift

tracker.trackError(errorId: "errorId")

Objective-C

[_tracker trackError:@"errorId"];
iOS (ACP 2.x)

trackError

Syntax

- (void) trackError: (NSString* _Nonnull) errorId;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackError:@"errorId"];

Swift

_tracker.trackError("errorId")
React Native

JavaScript

trackError

tracker.trackError("errorId");

trackEvent

Tracks media events.

Variable Name

Description

event

Media event

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.

data

Optional context data can be provided for AdStart and ChapterStart events. This is not required for other events.

Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Android

trackEvent

Syntax

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

Examples

Tracking player States

// StateStart
HashMap<String, Object> stateObject = Media.createStateObject("fullscreen");
_tracker.trackEvent(Media.Event.StateStart, stateObject, null);
// StateEnd
HashMap<String, Object> stateObject = Media.createStateObject("fullscreen");
_tracker.trackEvent(Media.Event.StateEnd, stateObject, null);

Tracking ad breaks

// AdBreakStart
HashMap<String, Object> adBreakObject = Media.createAdBreakObject("adbreak-name", 1L, 0D);
_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", 1L, 15D);
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);

Tracking chapters

// ChapterStart
HashMap<String, Object> chapterObject = Media.createChapterObject("chapter-name", 1L, 60D, 0D);
HashMap<String, String> chapterMetadata = new HashMap<String, String>();
chapterMetadata.put("segmentType", "Sample segment type");
_tracker.trackEvent(Media.Event.ChapterStart, chapterDataInfo, 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);

Tracking bitrate changes

// If the new bitrate value is available provide it to the tracker.
HashMap<String, Object> qoeObject = Media.createQoEObject(2000000L, 2D, 25D, 10D);
_tracker.updateQoEObject(qoeObject);
// Bitrate change
_tracker.trackEvent(Media.Event.BitrateChange, null, null);
iOS (AEP 3.x)

trackEvent

Syntax

func trackEvent(event: MediaEvent, info: [String: Any]?, metadata: [String: String]?)

Examples

Tracking player states

Swift

// StateStart
let fullScreenState = Media.createStateObjectWith(stateName: MediaConstants.PlayerState.FULLSCREEN)
tracker.trackEvent(event: MediaEvent.StateStart, info: fullScreenState, metadata: nil)
// StateEnd
let fullScreenState = Media.createStateObjectWith(stateName: MediaConstants.PlayerState.FULLSCREEN)
tracker.trackEvent(event: MediaEvent.StateEnd, info: fullScreenState, metadata: nil)

Objective-C

// StateStart
NSDictionary* fullScreenState = [AEPMobileMedia createStateObjectWith:AEPMediaPlayerState.FULLSCREEN];
[_tracker trackEvent:AEPMediaEventStateStart info:fullScreenState metadata:nil];
// StateEnd
NSDictionary* fullScreenState = [AEPMobileMedia createStateObjectWith:AEPMediaPlayerState.FULLSCREEN];
[_tracker trackEvent:AEPMediaEventStateEnd info:fullScreenState metadata:nil];

Tracking ad breaks

Swift

// AdBreakStart
let adBreakObject = Media.createAdBreakObjectWith(name: "adbreak-name", position: 1, startTime: 0)
tracker.trackEvent(event: MediaEvent.AdBreakStart, info: adBreakObject, metadata: nil)
// AdBreakComplete
tracker.trackEvent(event: MediaEvent.AdBreakComplete, info: nil, metadata: nil)

Objective-C

// AdBreakStart
NSDictionary *adBreakObject = [AEPMobileMedia createAdBreakObjectWith:@"adbreak-name" position:1 startTime:0];
[_tracker trackEvent:AEPMediaEventAdBreakStart info:adBreakObject metadata:nil];
// AdBreakComplete
[_tracker trackEvent:AEPMediaEventAdBreakComplete info:nil metadata:nil];

Tracking ads

Swift

// AdStart
let adObject = Media.createObjectWith(name: "adbreak-name", id: "ad-id", position: 0, length: 30)
// Standard metadata keys provided by adobe.
var adMetadata: [String: String] = [:]
adMetadata[MediaConstants.AdMetadataKeys.ADVERTISER] = "Sample Advertiser"
adMetadata[MediaConstants.AdMetadataKeys.CAMPAIGN_ID] = "Sample Campaign"
// Custom metadata keys
adMetadata["affiliate"] = "Sample affiliate"
tracker.trackEvent(event: MediaEvent.AdStart, info: adObject, metadata: adMetadata)
// AdComplete
tracker.trackEvent(event: MediaEvent.AdComplete, info: nil, metadata: nil)
// AdSkip
tracker.trackEvent(event: MediaEvent.AdSkip, info: nil, metadata: nil)

Objective-C

// AdStart
NSDictionary *adObject = [AEPMobileMedia createAdObjectWith:@"ad-name" id:@"ad-id" position:0 length:30];
NSMutableDictionary* adMetadata = [[NSMutableDictionary alloc] init];
// Standard metadata keys provided by adobe.
[adMetadata setObject:@"Sample Advertiser" forKey:AEPAdMetadataKeys.ADVERTISER];
[adMetadata setObject:@"Sample Campaign" forKey:AEPAdMetadataKeys.CAMPAIGN_ID];
// Custom metadata keys
[adMetadata setObject:@"Sample affiliate" forKey:@"affiliate"];
[_tracker trackEvent:AEPMediaEventAdStart info:adObject metadata:adMetadata];
// AdComplete
[_tracker trackEvent:AEPMediaEventAdComplete info:nil metadata:nil];
// AdSkip
[_tracker trackEvent:AEPMediaEventAdSkip info:nil metadata:nil];

Tracking chapters

Swift

// ChapterStart
let chapterObject = Media.createChapterObjectWith(name: "chapter_name", position: 1, length: 60, startTime: 0)
let chapterDictionary = ["segmentType": "Sample segment type"]
tracker.trackEvent(event: MediaEvent.ChapterStart, info: chapterObject, metadata: chapterDictionary)
// ChapterComplete
tracker.trackEvent(event: MediaEvent.ChapterComplete, info: nil, metadata: nil)
// ChapterSkip
tracker.trackEvent(event: MediaEvent.ChapterSkip, info: nil, metadata: nil)

Objective-C

// ChapterStart
NSDictionary *chapterObject = [AEPMobileMedia createChapterObjectWith:@"chapter_name" position:1 length:60 startTime:0];
NSMutableDictionary *chapterMetadata = [[NSMutableDictionary alloc] init];
[chapterMetadata setObject:@"Sample segment type" forKey:@"segmentType"];
[_tracker trackEvent:AEPMediaEventChapterStart info:chapterObject metadata:chapterMetadata];
// ChapterComplete
[_tracker trackEvent:AEPMediaEventChapterComplete info:nil metadata:nil];
// ChapterSkip
[_tracker trackEvent:AEPMediaEventChapterSkip info:nil metadata:nil];

Tracking playback events

Swift

// BufferStart
tracker.trackEvent(event: MediaEvent.BufferStart, info: nil, metadata: nil)
// BufferComplete
tracker.trackEvent(event: MediaEvent.BufferComplete, info: nil, metadata: nil)
// SeekStart
tracker.trackEvent(event: MediaEvent.SeekStart, info: nil, metadata: nil)
// SeekComplete
tracker.trackEvent(event: MediaEvent.SeekComplete, info: nil, metadata: nil)

Objective-C

// BufferStart
[_tracker trackEvent:AEPMediaEventBufferStart info:nil metadata:nil];
// BufferComplete
[_tracker trackEvent:AEPMediaEventBufferComplete info:nil metadata:nil];
// SeekStart
[_tracker trackEvent:AEPMediaEventSeekStart info:nil metadata:nil];
// SeekComplete
[_tracker trackEvent:AEPMediaEventSeekComplete info:nil metadata:nil];

Tracking bitrate change

Swift

// If the new bitrate value is available provide it to the tracker.
let qoeObject = Media.createQoEObjectWith(bitrate: 500000, startupTime: 2, fps: 24, droppedFrames: 10)
tracker.updateQoEObject(qoeObject)
// Bitrate change
tracker.trackEvent(event: MediaEvent.BitrateChange, info: nil, metadata: nil)

Objective-C

// If the new bitrate value is available provide it to the tracker.
NSDictionary *qoeObject = [AEPMobileMedia createQoEObjectWith:50000 startTime:2 fps:24 droppedFrames:10];
// Bitrate change
[_tracker trackEvent:AEPMediaEventBitrateChange info:nil metadata:nil];
iOS (ACP 2.x)

trackEvent

Syntax

- (void) trackEvent: (ACPMediaEvent) event
info: (NSDictionary* _Nullable) info
data: (NSDictionary* _Nullable) data;

Examples

Tracking player states

Here are examples in Objective-C and Swift:

Objective-C