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

Java

String mediaExtensionVersion = Media.extensionVersion();

Swift

Syntax
static var extensionVersion: String
Example
let mediaExtensionVersion = Media.extensionVersion()

Objective-C

Syntax
+ (nonnull NSString*) extensionVersion;
Example
NSString *mediaExtensionVersion = [AEPMobileMedia extensionVersion];

Swift

Syntax
+ (nonnull NSString*) extensionVersion;
Example
let mediaExtensionVersion = ACPMedia.extensionVersion()

Objective-C

Syntax
+ (NSString * _Nonnull)extensionVersion
Example
NSString *mediaExtensionVersion = [ACPMedia extensionVersion];

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

Java

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

Swift

Syntax
static func createTracker()
Example
let tracker = Media.createTracker() // Use the instance for tracking media.

Objective-C

Syntax
+ (void) createTracker
id<AEPMediaTracker> tracker;
_tracker = [AEPMobileMedia createTracker]; // Use the instance for tracking media.
The createTracker function returns the instance of ACPMediaTracker for tracking a media session. The createTracker function with callback as a parameter has been deprecated.

Swift

Syntax
static func createTracker()
Example
let mediaTracker = ACPMedia.createTracker() // Use the instance for tracking media.
// Deprecated
ACPMedia.createTracker({mediaTracker in
// Use the instance for tracking media.
})

Objective-C

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

JavaScript

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 in the Data Collection UI 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

Java

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 in the Data Collection UI
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.
}
});
Creates a media tracker instance based on the configuration to track the playback session.

Swift

Syntax
static func createTrackerWith(config: [String: Any]?)
Example
var config: [String: Any] = [:]
config[MediaConstants.TrackerConfig.CHANNEL] = "custom-channel" // Overrides channel configured in the Data Collection UI
config[MediaConstants.TrackerConfig.DOWNLOADED_CONTENT] = true // Creates downloaded content tracker
let tracker = Media.createTrackerWith(config: config)

Objective-C

Syntax
+(id<AEPMediaTracker> _Nonnull) createTrackerWithConfig:(NSDictionary<NSString *,id> * _Nullable)
Example
id<AEPMediaTracker> _tracker;
NSMutableDictionary* config = [NSMutableDictionary dictionary];
config[AEPMediaTrackerConfig.CHANNEL] = @"custom-channel"; // Overrides channel configured in the Data Collection UI
config[AEPMediaTrackerConfig.DOWNLOADED_CONTENT] = [NSNumber numberWithBool:true]; // Creates downloaded content tracker
_tracker = [AEPMobileMedia createTrackerWithConfig:config];
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.

Swift

Syntax
static func createTracker(withConfig config: [AnyHashable : Any]?)
Examples
var config: [String: Any] = [:]
config[ACPMediaKeyConfigChannel] = "custom-channel" // Override channel configured in the Data Collection UI
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.
}

Objective-C

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;
Example
NSMutableDictionary* config = [NSMutableDictionary dictionary];
config[ACPMediaKeyConfigChannel] = @"custom-channel"; // Override channel configured in the Data Collection UI
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.
}];

JavaScript

var config = new Object();
config[ACPMediaConstants.ACPMediaKeyConfigChannel] = "customer-channel"; // Override channel configured in the Data Collection UI
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
The name of the media
Yes
mediaId
The unqiue identifier for the media
Yes
length
The length of the media in seconds
Yes
streamType
Yes
mediaType
Yes
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native

Java

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);
Returns a map that contains information about the media.

Swift

Syntax
static func createMediaObjectWith(name: String,
id: String,
length: Double,
streamType: String,
mediaType: MediaType) -> [String: Any]?
Example
let mediaObject = Media.createMediaObjectWith(name: "video-name",
id: "videoId",
length: 60,
streamType: MediaConstants.StreamType.VOD,
mediaType: MediaType.Video)

Objective-C

Syntax
+ (NSDictionary<NSString *, id> * _Nullable) createMediaObjectWith:(NSString * _Nonnull) id:(NSString * _Nonnull) length:(double) streamType:(NSString * _Nonnull) mediaType:(enum AEPMediaType)
Example
NSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name"
id:@"video-id"
length:60
streamType:AEPMediaStreamType.VOD
mediaType:AEPMediaTypeVideo];
Returns an NSDictionary instance that contains information about the media.

Swift

Syntax
static func createMediaObject(withName name: String, mediaId: String, length: Double, streamType: String, mediaType: ACPMediaType)
Example
let mediaObject = ACPMedia.createMediaObject(withName: "video-name", mediaId: "video-id",
length: Double(60),
streamType: ACPMediaStreamTypeVod,
mediaType:ACPMediaType.video)

Objective-C

Syntax
+ (NSDictionary* _Nonnull) createMediaObjectWithName: (NSString* _Nonnull) name
mediaId: (NSString* _Nonnull) mediaId
length: (double) length
streamType: (NSString* _Nonnull) streamType
mediaType: (ACPMediaType) mediaType;
Example
NSDictionary *mediaObject = [ACPMedia createMediaObjectWithName: @"video-name"
mediaId: @"video-id"
length: 60
streamType: ACPMediaStreamTypeVod
mediaType: ACPMediaTypeVideo];

JavaScript

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

Java

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);
Returns a map that contains information about the ad break.

Swift

Syntax
static func createAdBreakObjectWith(name: String,
position: Int,
startTime: Double) -> [String: Any]?
Example
let adBreakObject = Media.createAdBreakObjectWith(name: "adbreak-name",
position: 1,
startTime: 0)

Objective-C

Syntax
+ (NSDictionary <NSString *, id> * _Nullable) createAdBreakObjectWith:(NSString * _Nonnull)position:(NSInteger) startTime:(double)
Example
NSDictionary *adBreakObject = [AEPMobileMedia createAdBreakObjectWith:@"adbreak-name"
position:1
startTime:0];
Returns an NSDictionary instance that contains information about the ad break.

Swift

Syntax
static func createAdBreakObject(withName name: String,
position: Double, tartTime: Double)
Example
let adBreakObject = ACPMedia.createAdBreakObject(withName: "adbreak-name",
position: 1,
startTime: 0)

Objective-C

Syntax
+ (NSDictionary* _Nonnull) createAdBreakObjectWithName: (NSString* _Nonnull) name
position: (double) position
startTime: (double) startTime;
Example
NSDictionary *adBreakObject = [ACPMedia createAdBreakObjectWithName: @"adbreak-name"
position: 1
startTime: 0];

JavaScript

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 in seconds
Yes
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native

Java

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);
Returns a map that contains information about the ad.

Swift

Syntax
static func createAdObjectWith(name: String,
id: String,
position: Int,
length: Double) -> [String: Any]?
Example
let adObject = Media.createObjectWith(name: "ad-name",
id: "ad-id",
position: 0,
length: 30)

Objective-C

Syntax
+ (NSDictionary <NSString *, id> * _Nullable) createAdObjectWith: (NSString * _Nonnull
id:(NSString * _Nonnull)
position:(NSInteger)
length:(double)
Example
NSDictionary *adObject = [AEPMobileMedia createAdObjectWith:@"ad-name"
id:@"ad-id"
position:0
length:30];
Returns an NSDictionary instance that contains information about the ad.

Swift

Syntax
static func createAdObject(withName name: String,
adId: String,
position: Double,
length: Double)
Example
let adObject = ACPMedia.createAdObject(withName: "ad-name",
adId: "ad-id",
position: 1,
length: 15)

Objective-C

Syntax
+ (NSDictionary* _Nonnull) createAdObjectWithName: (NSString* _Nonnull) name
adId: (NSString* _Nonnull) adId
position: (double) position
length: (double) length;
Example
NSDictionary *adObject = [ACPMedia createAdObjectWithName: @"ad-name"
adId: @"ad-id"
position: 1
length: 15];

JavaScript

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 in seconds
Yes
startTime
Playhead value at the start of the chapter
Yes
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native

Java

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);
Returns a map that contains information about the chapter.

Swift

Syntax
static func createChapterObjectWith(name: String,
position: Int,
length: Double,
startTime: Double) -> [String: Any]?
Example
let chapterObject = Media.createChapterObjectWith(name: "chapter_name",
position: 1,
length: 60,
startTime: 0)

Objective-C

Syntax
+ (NSDictionary <NSString *, id> * _Nullable) createChapterObjectWith:(NSString * _Nonnull)
position:(NSInteger)
length:(double)
startTime:(double)
Example
NSDictionary *chapterObject = [AEPMobileMedia createChapterObjectWith:@"chapter_name"
position:1
length:60
startTime:0];
Returns an NSDictionary instance that contains information about the chapter.

Swift

Syntax
static func createChapterObject(withName name: String,
position: Double,
length: Double,
startTime: Double)
Example
let chapterObject = ACPMedia.createChapterObject(withName: "chapter-name", position: 1, length: 60, startTime: 0)

Objective-C

Syntax
+ (NSDictionary* _Nonnull) createChapterObjectWithName: (NSString* _Nonnull) name
position: (double) position
length: (double) length
startTime: (double) startTime;
Example
NSDictionary *chapterObject = [ACPMedia createChapterObjectWithName: @"chapter-name"
position: 1
length: 60
startTime: 0];

JavaScript

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

createQoEObject

Creates an instance of the QoE object.
Variable Name
Description
Required
bitrate
The bitrate of media in bits per second
Yes
startupTime
The start up time of media in seconds
Yes
fps
The current frames per second information
Yes
droppedFrames
The number of dropped frames so far
Yes
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

Java

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);
Returns a map that contains information about the quality of experience.

Swift

Syntax
static func createQoEObjectWith(bitrate: Double,
startupTime: Double,
fps: Double,
droppedFrames: Double) -> [String: Any]?
Example
let qoeObject = Media.createQoEObjectWith(bitrate: 500000,
startupTime: 2,
fps: 24,
droppedFrames: 10)

Objective-C

Syntax
+ (NSDictionary <NSString *, id> * _Nullable) createQoEObjectWith:(double)
startTime:(double)
fps:(double)
droppedFrames:(double)
Example
NSDictionary *qoeObject = [AEPMobileMedia createQoEObjectWith:500000
startTime:2
fps:24
droppedFrames:10];
Returns an NSDictionary instance that contains information about the quality of experience.

Swift

Syntax
static func createQoEObject(withBitrate bitrate: Double,
startupTime: Double,
fps: Double,
droppedFrames: Double)
Example
let qoeObject = ACPMedia.createQoEObject(withBitrate: 10000000, startupTime: 2, fps: 23, droppedFrames: 10)

Objective-C

Syntax
+ (NSDictionary* _Nonnull) createQoEObjectWithBitrate: (double) bitrate
startupTime: (double) startupTime
fps: (double) fps
droppedFrames: (double) droppedFrames;
NSDictionary *qoeObject = [ACPMedia createQoEObjectWithBitrate: 10000000
startupTime: 2
fps: 23
droppedFrames: 10];

JavaScript

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
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");
Returns a map that contains information about the player state.

Swift

Syntax
static func createStateObjectWith(stateName: String) -> [String: Any]
Example
let fullScreenState = Media.createStateObjectWith(stateName: "fullscreen")

Objective-C

Syntax
+ (NSDictionary <NSString *, id> * _Nullable) createStateObjectWith:(NSString * _Nonnull)
Example
NSDictionary* fullScreenState = [AEPMobileMedia createStateObjectWith:AEPMediaPlayerState.FULLSCREEN]
Returns an NSDictionary instance that contains information about the player state.

Swift

Syntax