Media API reference

Media API reference

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
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.

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

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
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

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
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

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
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

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
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

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
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

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
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

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
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

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. For more information, see Media Resume.

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
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

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
React Native
Android

trackPlay

Syntax

public void trackPlay();

Example

_tracker.trackPlay();
iOS

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
React Native
Android

trackPause

Syntax

public void trackPause();

Example

_tracker.trackPause();
iOS

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
React Native
Android

trackComplete

Syntax

public void trackComplete();

Example

_tracker.trackComplete();
iOS

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
React Native
Android

trackSessionEnd

Syntax

public void trackSessionEnd();

Example

_tracker.trackSessionEnd();
iOS

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
React Native
Android

trackError

Syntax

public void trackError(String errorId);

Example

_tracker.trackError("errorId");
iOS

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
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 AdBreaks

// 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

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

// StateStart
NSDictionary* stateObject = [ACPMedia createStateObjectWithName:@"fullscreen"];
[_tracker trackEvent:ACPMediaEventStateStart mediaObject:stateObject data:nil];
// StateEnd
NSDictionary* stateObject = [ACPMedia createStateObjectWithName:@"fullscreen"];
[_tracker trackEvent:ACPMediaEventStateEnd mediaObject:stateObject data:nil];

Swift

// StateStart
let stateObject = ACPMedia.createStateObject(withName: "fullscreen")
_tracker.trackEvent(ACPMediaEvent.stateStart, mediaObject: stateObject, data: nil)
// StateEnd
let stateObject = ACPMedia.createStateObject(withName: "fullscreen")
_tracker.trackEvent(ACPMediaEvent.stateEnd, mediaObject: stateObject, data: nil)

Tracking AdBreaks

Here are examples in Objective C and Swift:

Objective C

// AdBreakStart
NSDictionary* adBreakObject = [ACPMedia createAdBreakObjectWithName:@"adbreak-name" position:1 startTime:0];
[_tracker trackEvent:ACPMediaEventAdBreakStart mediaObject:adBreakObject data:nil];
// AdBreakComplete
[_tracker trackEvent:ACPMediaEventAdBreakComplete mediaObject:nil data:nil];

Swift

// AdBreakStart
let adBreakObject = ACPMedia.createAdBreakObject(withName: "adbreak-name", position: 1, startTime: 0)
_tracker.trackEvent(ACPMediaEvent.adBreakStart, mediaObject: adBreakObject, data: nil)
// AdBreakComplete
_tracker.trackEvent(ACPMediaEvent.adBreakComplete, mediaObject: nil, data: nil)

Tracking Ads

Here are examples in Objective C and Swift:

Objective C

// AdStart
NSDictionary* adObject = [ACPMedia createAdObjectWithName:@"ad-name" adId:@"ad-id" position:1 length:15];
NSMutableDictionary* adMetadata = [[NSMutableDictionary alloc] init];
// Standard metadata keys provided by adobe.
[adMetadata setObject:@"Sample Advertiser" forKey:ACPAdMetadataKeyAdvertiser];
[adMetadata setObject:@"Sample Campaign" forKey:ACPAdMetadataKeyCampaignId];
// Custom metadata keys
[adMetadata setObject:@"Sample affiliate" forKey:@"affiliate"];
[_tracker trackEvent:ACPMediaEventAdStart mediaObject:adObject data:adMetadata];
// AdComplete
[_tracker trackEvent:ACPMediaEventAdComplete mediaObject:nil data:nil];
// AdSkip
[_tracker trackEvent:ACPMediaEventAdSkip mediaObject:nil data:nil];

Swift

// AdStart
let adObject = ACPMedia.createAdObject(withName: "ad-name", adId: "ad-id", position: 1, length: 15)
// Standard metadata keys provided by adobe.
var adMetadata = [ACPAdMetadataKeyAdvertiser: "Sample Advertiser", ACPAdMetadataKeyCampaignId: "Sample Campaign"]
// Custom metadata keys
adMetadata["affiliate"] = "Sample affiliate"
_tracker.trackEvent(ACPMediaEvent.adStart, mediaObject: adObject, data: adMetadata)
// AdComplete
_tracker.trackEvent(ACPMediaEvent.adComplete, mediaObject: nil, data: nil)
// AdSkip
_tracker.trackEvent(ACPMediaEvent.adSkip, mediaObject: nil, data: nil)

Tracking Chapters

Here are examples in Objective C and Swift:

Objective C

// ChapterStart
NSDictionary* chapterObject = [ACPMedia createChapterObjectWithName:@"chapter-name" position:1 length:30 startTime:0];
NSMutableDictionary *chapterMetadata = [[NSMutableDictionary alloc] init];
[chapterMetadata setObject:@"Sample segment type" forKey:@"segmentType"];
[_tracker trackEvent:ACPMediaEventChapterStart mediaObject:chapterObject data:chapterMetadata];
// ChapterComplete
[_tracker trackEvent:ACPMediaEventChapterComplete mediaObject:nil data:nil];
// ChapterSkip
[_tracker trackEvent:ACPMediaEventChapterSkip mediaObject:nil data:nil];

Swift

// ChapterStart
let chapterObject = ACPMedia.createChapterObject(withName: "chapter-name", position: 1, length: 60, startTime: 0)
let chapterMetadata = ["Sample segment type": "segmentType"];
_tracker.trackEvent(ACPMediaEvent.chapterStart, mediaObject: chapterObject, data: chapterMetadata)
// ChapterComplete
_tracker.trackEvent(ACPMediaEvent.chapterComplete, mediaObject: nil, data: nil)
// ChapterSkip
_tracker.trackEvent(ACPMediaEvent.chapterSkip, mediaObject: nil, data: nil)

Tracking Playback events

Here are examples in Objective C and Swift:

Objective C

// BufferStart
[_tracker trackEvent:ACPMediaEventBufferStart info:nil data:nil];
// BufferComplete
[_tracker trackEvent:ACPMediaEventBufferComplete info:nil data:nil];
// SeekStart
[_tracker trackEvent:ACPMediaEventSeekStart info:nil data:nil];
// SeekComplete
[_tracker trackEvent:ACPMediaEventSeekComplete info:nil data:nil];

Swift

// BufferStart
_tracker.trackEvent(ACPMediaEvent.bufferStart, mediaObject: nil, data: nil)
// BufferComplete
_tracker.trackEvent(ACPMediaEvent.bufferComplete, mediaObject: nil, data: nil)
// SeekStart
_tracker.trackEvent(ACPMediaEvent.seekStart, mediaObject: nil, data: nil)
// SeekComplete
_tracker.trackEvent(ACPMediaEvent.seekComplete, mediaObject: nil, data: nil)

Tracking Bitrate change

Here are examples in Objective C and Swift:

Objective C

// If the new bitrate value is available provide it to the tracker.
NSDictionary* qoeObject = [ACPMedia createQoEObjectWithBitrate:2000000 startupTime:2 fps:25 droppedFrames:10];
[_tracker updateQoEObject:qoeObject];
// Bitrate change
[_tracker trackEvent:ACPMediaEventBitrateChange info:nil data:nil];

Swift

// If the new bitrate value is available provide it to the tracker.
let qoeObject = ACPMedia.createQoEObject(withBitrate: 2000000, startupTime: 2, fps: 25, droppedFrames: 10)
_tracker.updateQoEObject(qoeObject)
// Bitrate change
_tracker.trackEvent(ACPMediaEvent.bitrateChange, mediaObject: nil, data: nil)
React Native

JavaScript

trackEvent

Examples

Tracking Player States

// StateStart
let stateObject = ACPMedia.createStateObject("fullscreen");
tracker.trackEvent(ACPMediaEvent.EventStateStart, stateObject, null);
// StateEnd
let stateObject = ACPMedia.createStateObject("fullscreen");
tracker.trackEvent(ACPMediaEvent.EventStateEnd, stateObject, null);

Tracking AdBreaks

// AdBreakStart
let adBreakObject = ACPMedia.createAdBreakObject("adbreak-name", 1, 0);
tracker.trackEvent(ACPMediaEvent.EventAdBreakStart, adBreakObject, null);
// AdBreakComplete
tracker.trackEvent(ACPMediaEvent.EventAdBreakComplete, null, null);

Tracking ads

// AdStart
let adObject = ACPMedia.createAdObject("ad-name", "ad-id", 1, 15);
var adMetadata = new Object();
adMetadata[ACPMediaConstants.ACPAdMetadataKeyAdvertiser] = "Sample Advertiser";
adMetadata[ACPMediaConstants.ACPAdMetadataKeyCampaignId] = "Sample Campaign";
// Custom metadata keys
adMetadata["affiliate"] = "Sample affiliate";
tracker.trackEvent(ACPMediaEvent.EventAdStart, adObject, adMetadata);
// AdComplete
tracker.trackEvent(ACPMediaEvent.EventAdComplete, null, null);
// AdSkip
tracker.trackEvent(ACPMediaEvent.EventAdSkip, null, null);

Tracking chapters

// ChapterStart
let chapterObject = ACPMedia.createChapterObject("chapter-name", 1, 60, 0);
var chapterMetadata = new Object();
chapterMetadata["segmentType"] = "Sample segment type";
tracker.trackEvent(ACPMediaEvent.EventChapterStart, chapterObject, chapterMetadata);
// ChapterComplete
tracker.trackEvent(ACPMediaEvent.EventChapterComplete, null, null);
// ChapterSkip
tracker.trackEvent(ACPMediaEvent.EventChapterSkip, null, null);

Tracking playback events

// BufferStart
tracker.trackEvent(ACPMediaEvent.EventBufferStart, null, null);
// BufferComplete
tracker.trackEvent(ACPMediaEvent.EventBufferComplete, null, null);
// SeekStart
tracker.trackEvent(ACPMediaEvent.EventSeekStart, null, null);
// SeekComplete
tracker.trackEvent(ACPMediaEvent.EventSeekComplete, null, null);

Tracking bitrate changes

// If the new bitrate value is available provide it to the tracker.
let qoeObject = ACPMedia.createQoEObject(2000000, 2, 25, 10);
tracker.updateQoEObject(qoeObject);
// Bitrate change
tracker.trackEvent(ACPMediaEvent.EventBitrateChange, null, null);

updateCurrentPlayhead

Provides a media tracker with the current media playhead. For accurate tracking, call this method multiple times when the playhead changes.

Variable Name

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, returns the playhead position if available or the current UTC time in seconds if not available.

Android
iOS
React Native
Android

updateCurrentPlayhead

Syntax

public void updateCurrentPlayhead(double time);

Example

_tracker.updateCurrentPlayhead(1);
iOS

updateCurrentPlayhead

Syntax

- (void) updateCurrentPlayhead: (double) time;

Example

Here are examples in Objective C and Swift:

Objective C

[_tracker updateCurrentPlayhead:1];

Swift

_tracker.updateCurrentPlayhead(1)
React Native

JavaScript

updateCurrentPlayhead

tracker.updateCurrentPlayhead(1);

updateQoEObject

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.

Variable Name

Description

qoeObject

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

Android
iOS
React Native
Android

updateQoEObject

Syntax

public void updateQoEObject(Map<String, Object> qoeObject);

Example

HashMap<String, Object> qoeObject = Media.createQoEObject(1000000L, 2D, 25D, 10D);
_tracker.updateQoEObject(qoeObject);
iOS

updateQoEObject

Syntax

- (void) updateQoEObject: (NSDictionary* _Nonnull) qoeObject;

Example

Here are examples in Objective C and Swift:

Objective C

NSDictionary* qoeObject = [ACPMedia createQoEObjectWithBitrate:1000000 startupTime:2 fps:25 droppedFrames:10];
[_tracker updateQoEObject:qoeObject];

Swift

let qoeObject = ACPMedia.createQoEObject(withBitrate: 1000000, startupTime: 2, fps: 25, droppedFrames: 10)
_tracker.updateQoEObject(qoeObject