Media API reference

Media API reference

Create a media tracker

Creates a media tracker instance that tracks the playback session. The tracker created should be used for tracking streaming content and it sends periodic pings to the media analytics backend.

Android
iOS

createTracker

The callback is invoked to return the created tracker instance. If an error occurs, null is returned.

Syntax

public static void createTracker(AdobeCallback<MediaTracker> callback)

Example

Media.createTracker(new AdobeCallback<MediaTracker>() {
@Override
public void call(MediaTracker tracker) {
// Use the instance for tracking media.
}
});

createTracker

The callback will be invoked to return the created tracker instance. If an error occurs, nil is returned.

Syntax

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

Examples

Here are examples in Objective-C and Swift:

Objective-C

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

Swift

ACPMedia.createTracker({mediaTracker in
// Use the instance for tracking media.
}

Create a media tracker with optional configuration

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 for tracking downloaded media. The tracker will not send periodic pings and will only send a single ping for entire content.

Boolean

No

Android
iOS

createTracker

Optional configuration about the tracker can be passed to this function. The callback is invoked to return the created tracker instance. If an error occurs, null is returned.

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 void createTracker(Map<String, Object> config, final AdobeCallback<MediaTracker> callback)

Example

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

createTrackerWithConfig

Optional configuration about the tracker can be passed to this function. The callback is invoked to return the created tracker instance. If an error occurs, null is returned.

Syntax

FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaKeyConfigChannel;
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaKeyConfigDownloadedContent;
+ (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"; // Creates downloaded content tracker
config[ACPMediaKeyConfigDownloadedContent] = @YES; // Override channel configured from launch
[ACPMedia createTrackerWithConfig: config
callback:^(ACPMediaTracker * _Nullable mediaTracker) {
// Use the instance for tracking media.
}];

Swift

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

Create a media object

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

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

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)

Create an AdBreak object

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

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

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)

Create an ad object

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

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

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)

Create a chapter object

Creates an instance of the Chapter object.

Variable Name

Description

Required

name

Chapter name

Yes

position

Chapter position

Yes

length

Chapter length

Yes

startTime

Chapter start time

Yes

Android
iOS

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

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)

Create a QoE object

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

Android
iOS

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

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)

Media tracker API reference

trackSessionStart

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

Yes

contextData

Optional Media context data. For standard metadata keys, use standard video constants or standard audio constants.

No

Android
iOS

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

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)

trackPlay

Track media play or resume after a previous pause.

Android
iOS

trackPlay

Syntax

public void trackPlay();

Example

_tracker.trackPlay();

trackPlay

Syntax

- (void) trackPlay;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackPlay];

Swift

_tracker.trackPlay()

trackPause

Track media pause.

Android
iOS

trackPause

Syntax

public void trackPause();

Example

_tracker.trackPause();

trackPause

Syntax

- (void) trackPause;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackPause];

Swift

_tracker.trackPause()

trackComplete

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

Android
iOS

trackComplete

Syntax

public void trackComplete();

Example

_tracker.trackComplete();

trackComplete

Syntax

- (void) trackComplete;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackComplete];

Swift

_tracker.trackComplete()

trackSessionEnd

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

Android
iOS

trackSessionEnd

Syntax

public void trackSessionEnd();

Example

_tracker.trackSessionEnd();

trackSessionEnd

Syntax

- (void) trackSessionEnd;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker trackSessionEnd];

Swift

_tracker.trackSessionEnd()

trackError

Track an error in media playback.

Variable Name

Description

Required

errorId

Error Information

Yes

Android
iOS

trackError

Syntax

public void trackError(String errorId);

Example

_tracker.trackError("errorId");

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

trackEvent

Method to track media events.

Variable Name

Description

event

Media event

info

For an AdBreakStart event, the adBreak information is created by using a Create AdBreak Object. For an AdStart event, the Ad information is created by using a Create Ad Object. For ChapterStart event, the Chapter information is created by using a Create Chapter Object. This is not required for other events.

data

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

Android
iOS

trackEvent

Syntax

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

Examples

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
_heartbeat.trackEvent(Media.Event.BitrateChange, null, null);

trackEvent

Syntax

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

Examples

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)

updateCurrentPlayhead

Provide 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

updateCurrentPlayhead

Syntax

public void updateCurrentPlayhead(double time);

Example

_tracker.updateCurrentPlayhead(1);

updateCurrentPlayhead

Syntax

- (void) updateCurrentPlayhead: (double) time;

Example

Here are examples in Objective-C and Swift:

Objective-C

[_tracker updateCurrentPlayhead:1];

Swift

_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 a Create QoE Object.

Android
iOS

updateQoEObject

Syntax

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

Example

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

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)

Media constants

MediaType

This defines the type of a media that is currently tracked.

Android
iOS
public class Media {
public enum MediaType {
/**
* Constant defining media type for Video streams
*/
Video,
/**
* Constant defining media type for Audio streams
*/
Audio
}
}
typedef NS_ENUM(NSInteger, ACPMediaType) {
/**
* Constant defining media type for Video streams
*/
ACPMediaTypeVideo,
/**
* Constant defining media type for Audio streams
*/
ACPMediaTypeAudio
};

StreamType

This defines the stream type of the content that is currently tracked.

Android
iOS
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";
}
}
/**
* Constant defining stream type for VOD streams
*/
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaStreamTypeVod;
/**
* Constant defining stream type for Live streams
*/
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaStreamTypeLive;
/**
* Constant defining stream type for Linear streams
*/
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaStreamTypeLinear;
/**
* Constant defining stream type for Podcast streams
*/
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaStreamTypePodcast;
/**
* Constant defining stream type for Audiobook streams
*/
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaStreamTypeAudiobook;
/**
* Constant defining stream type for AOD streams
*/
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaStreamTypeAod;

Standard video constants

This defines the standard metadata keys for video streams.

Android
iOS
public class MediaConstants {
public static final class VideoMetadataKeys {
public static final String SHOW = "a.media.show";
public static final String SEASON = "a.media.season";
public static final String EPISODE = "a.media.episode";
public static final String ASSET_ID = "a.media.asset";
public static final String GENRE = "a.media.genre";
public static final String FIRST_AIR_DATE = "a.media.airDate";
public static final String FIRST_DIGITAL_DATE = "a.media.digitalDate";
public static final String RATING = "a.media.rating";
public static final String ORIGINATOR = "a.media.originator";
public static final String NETWORK = "a.media.network";
public static final String SHOW_TYPE = "a.media.type";
public static final String AD_LOAD = "a.media.adLoad";
public static final String MVPD = "a.media.pass.mvpd";
public static final String AUTHORIZED = "a.media.pass.auth";
public static final String DAY_PART = "a.media.dayPart";
public static final String FEED = "a.media.feed";
public static final String STREAM_FORMAT = "a.media.format";
}
}
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyShow;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeySeason;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyEpisode;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyAssetId;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyGenre;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyFirstAirDate;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyFirstDigitalDate;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyRating;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyOriginator;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyNetwork;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyShowType;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyAdLoad;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyMvpd;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyAuthorized;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyDayPart;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyFeed;
FOUNDATION_EXPORT NSString* _Nonnull const ACPVideoMetadataKeyStreamFormat;

Standard audio constants

This defines the standard metadata keys for audio streams.

Android
iOS
public class MediaConstants {
public static final class AudioMetadataKeys {
public static final String ARTIST = "a.media.artist";
public static final String ALBUM = "a.media.album";
public static final String LABEL = "a.media.label";
public static final String AUTHOR = "a.media.author";
public static final String STATION = "a.media.station";
public static final String PUBLISHER = "a.media.publisher";
}
}
FOUNDATION_EXPORT NSString* _Nonnull const ACPAudioMetadataKeyArtist;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAudioMetadataKeyAlbum;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAudioMetadataKeyLabel;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAudioMetadataKeyAuthor;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAudioMetadataKeyStation;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAudioMetadataKeyPublisher;

Standard ad constants

This defines the standard metadata keys for ads.

Android
iOS
public class MediaConstants {
public static final class AdMetadataKeys {
public static final String ADVERTISER = "a.media.ad.advertiser";
public static final String CAMPAIGN_ID = "a.media.ad.campaign";
public static final String CREATIVE_ID = "a.media.ad.creative";
public static final String PLACEMENT_ID = "a.media.ad.placement";
public static final String SITE_ID = "a.media.ad.site";
public static final String CREATIVE_URL = "a.media.ad.creativeURL";
}
}
FOUNDATION_EXPORT NSString* _Nonnull const ACPAdMetadataKeyAdvertiser;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAdMetadataKeyCampaignId;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAdMetadataKeyCreativeId;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAdMetadataKeyPlacementId;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAdMetadataKeySiteId;
FOUNDATION_EXPORT NSString* _Nonnull const ACPAdMetadataKeyCreativeUrl;

Media events

This defines the type of a tracking event.

Android
iOS
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,
}
}
/**
* These enumeration values define the type of a tracking event
*/
typedef NS_ENUM(NSInteger, ACPMediaEvent) {
/**
* Constant defining event type for AdBreak start
*/
ACPMediaEventAdBreakStart,
/**
* Constant defining event type for AdBreak complete
*/
ACPMediaEventAdBreakComplete,
/**
* Constant defining event type for Ad start
*/
ACPMediaEventAdStart,
/**
* Constant defining event type for Ad complete
*/
ACPMediaEventAdComplete,
/**
* Constant defining event type for Ad skip
*/
ACPMediaEventAdSkip,
/**
* Constant defining event type for Chapter start
*/
ACPMediaEventChapterStart,
/**
* Constant defining event type for Chapter complete
*/
ACPMediaEventChapterComplete,
/**
* Constant defining event type for Chapter skip
*/
ACPMediaEventChapterSkip,
/**
* Constant defining event type for Seek start
*/
ACPMediaEventSeekStart,
/**
* Constant defining event type for Seek complete
*/
ACPMediaEventSeekComplete,
/**
* Constant defining event type for Buffer start
*/
ACPMediaEventBufferStart,
/**
* Constant defining event type for Buffer complete
*/
ACPMediaEventBufferComplete,
/**
* Constant defining event type for change in Bitrate
*/
ACPMediaEventBitrateChange,
};

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.

Android
iOS

Media resume

Syntax

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

HashMap<String, Object> mediaObject = Media.createMediaObject("media-name", "media-id", 60D, MediaConstants.StreamType.VOD, Media.MediaType.Video);
// Attach media resumed information.
mediaObject.put(MediaConstants.MediaObjectKey.RESUMED, true);
_heartbeat.trackSessionStart(mediaObject, null);

Media Resume

Syntax

FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaKeyMediaResumed;

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];
// Attach media resumed information.
NSMutableDictionary *obj = [mediaObject mutableCopy];
[obj setObject:@YES forKey:ACPMediaKeyMediaResumed];
[_tracker trackSessionStart:obj data:nil];

Swift

var mediaObject = ACPMedia.createMediaObject(withName: "media-name", mediaId: "media-id", length: 60, streamType: ACPMediaStreamTypeVod, mediaType:ACPMediaType.video)
// Attach media resumed information.
mediaObject[ACPMediaKeyMediaResumed] = true
_tracker.trackSessionStart(mediaObject, data: nil)