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

1
String mediaExtensionVersion = Media.extensionVersion();
Copied!

Swift

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

Objective-C

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

Swift

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

Objective-C

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

JavaScript

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

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
1
public static MediaTracker createTracker()
2
3
// Deprecated
4
public static void createTracker(AdobeCallback<MediaTracker> callback)
Copied!
Example
1
MediaTracker mediaTracker = Media.createTracker(); // Use the instance for tracking media.
2
3
// Deprecated
4
Media.createTracker(new AdobeCallback<MediaTracker>() {
5
@Override
6
public void call(MediaTracker mediaTracker) {
7
// Use the instance for tracking media.
8
}
9
});
Copied!
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
1
static func createTracker()
Copied!
Example
1
let tracker = Media.createTracker() // Use the instance for tracking media.
Copied!

Objective-C

Syntax
1
+ (void) createTracker
Copied!
1
id<AEPMediaTracker> tracker;
2
_tracker = [AEPMobileMedia createTracker]; // Use the instance for tracking media.
Copied!
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
1
static func createTracker()
Copied!
Example
1
let mediaTracker = ACPMedia.createTracker() // Use the instance for tracking media.
2
3
// Deprecated
4
ACPMedia.createTracker({mediaTracker in
5
// Use the instance for tracking media.
6
})
Copied!

Objective-C

Syntax
1
+(ACPMediaTracker* _Nullable) createTracker;
2
3
// Deprecated
4
+(void) createTracker: (void (^ _Nonnull) (ACPMediaTracker* _Nullable)) callback;
Copied!
Example
1
ACPMediaTracker *mediaTracker = [ACPMedia createTracker]; // Use the instance for tracking media.
2
3
// Deprecated
4
[ACPMedia createTracker:^(ACPMediaTracker * _Nullable mediaTracker) {
5
// Use the instance for tracking media.
6
}];
Copied!

JavaScript

1
ACPMedia.createTracker().then(tracker =>
2
this.setState({currentTracker: tracker})
3
);
Copied!

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
1
public class MediaConstants {
2
3
public static final class Config {
4
public static final String CHANNEL = "config.channel";
5
public static final String DOWNLOADED_CONTENT = "config.downloadedcontent";
6
}
7
8
}
9
10
public static MediaTracker createTracker(Map<String, Object> config)
11
12
// Deprecated
13
public static void createTracker(Map<String, Object> config, final AdobeCallback<MediaTracker> callback)
Copied!
Example
1
HashMap<String, Object> config = new HashMap<String, Object>();
2
config.put(MediaConstants.Config.CHANNEL, "custom-channel"); // Override channel configured in the Data Collection UI
3
config.put(MediaConstants.Config.DOWNLOADED_CONTENT, true); // Creates downloaded content tracker
4
5
6
MediaTracker mediaTracker = Media.createTracker(config); // Use the instance for tracking media.
7
8
// Deprecated
9
Media.createTracker(config, new AdobeCallback<MediaTracker>() {
10
@Override
11
public void call(MediaTracker mediaTracker) {
12
// Use the instance for tracking media.
13
}
14
});
Copied!
Creates a media tracker instance based on the configuration to track the playback session.

Swift

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

Objective-C

Syntax
1
+(id<AEPMediaTracker> _Nonnull) createTrackerWithConfig:(NSDictionary<NSString *,id> * _Nullable)
Copied!
Example
1
id<AEPMediaTracker> _tracker;
2
NSMutableDictionary* config = [NSMutableDictionary dictionary];
3
4
config[AEPMediaTrackerConfig.CHANNEL] = @"custom-channel"; // Overrides channel configured in the Data Collection UI
5
config[AEPMediaTrackerConfig.DOWNLOADED_CONTENT] = [NSNumber numberWithBool:true]; // Creates downloaded content tracker
6
7
_tracker = [AEPMobileMedia createTrackerWithConfig:config];
Copied!
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
1
static func createTracker(withConfig config: [AnyHashable : Any]?)
Copied!
Examples
1
var config: [String: Any] = [:]
2
config[ACPMediaKeyConfigChannel] = "custom-channel" // Override channel configured in the Data Collection UI
3
config[ACPMediaKeyConfigDownloadedContent] = true // Creates downloaded content tracker
4
5
let mediaTracker = ACPMedia.createTrackerWithConfig(config); // Use the instance for tracking media.
6
7
// Deprecated
8
ACPMedia.createTrackerWithConfig(config, {mediaTracker in
9
// Use the instance for tracking media.
10
}
Copied!

Objective-C

Syntax
1
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaKeyConfigChannel;
2
FOUNDATION_EXPORT NSString* _Nonnull const ACPMediaKeyConfigDownloadedContent;
3
4
+ (ACPMediaTracker* _Nullable) createTrackerWithConfig: (NSDictionary* _Nullable) config;
5
6
// Deprecated
7
+ (void) createTrackerWithConfig: (NSDictionary* _Nullable) config
8
callback: (void (^ _Nonnull) (ACPMediaTracker* _Nullable)) callback;
Copied!
Example
1
NSMutableDictionary* config = [NSMutableDictionary dictionary];
2
config[ACPMediaKeyConfigChannel] = @"custom-channel"; // Override channel configured in the Data Collection UI
3
config[ACPMediaKeyConfigDownloadedContent] = @YES; // Creates downloaded content tracker
4
5
ACPMediaTracker *mediaTracker = [ACPMedia createTrackerWithConfig:config]; // Use the instance for tracking media.
6
7
// Deprecated
8
[ACPMedia createTrackerWithConfig: config
9
callback:^(ACPMediaTracker * _Nullable mediaTracker) {
10
// Use the instance for tracking media.
11
}];
Copied!

JavaScript

1
var config = new Object();
2
config[ACPMediaConstants.ACPMediaKeyConfigChannel] = "customer-channel"; // Override channel configured in the Data Collection UI
3
config[ACPMediaConstants.ACPMediaKeyConfigDownloadedContent] = true; // Creates downloaded content tracker
4
ACPMedia.createTrackerWithConfig(config).then(tracker =>
5
this.setState({currentTracker: tracker})
6
);
Copied!

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
1
public static HashMap<String, Object> createMediaObject(String name,
2
String mediaId,
3
Double length,
4
String streamType,
5
MediaType mediaType);
Copied!
Example
1
HashMap<String, Object> mediaInfo = Media.createMediaObject("video-name",
2
"video-id",
3
60D,
4
MediaConstants.StreamType.VOD,
5
Media.MediaType.Video);
Copied!
Returns a map that contains information about the media.

Swift

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

Objective-C

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

Swift

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

Objective-C

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

JavaScript

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

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
1
public static HashMap<String, Object> createAdBreakObject(String name, Long position, Double startTime);
Copied!
Example
1
HashMap<String, Object> adBreakObject = Media.createAdBreakObject("adbreak-name", 1L, 0D);
Copied!
Returns a map that contains information about the ad break.

Swift

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

Objective-C

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

Swift

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

Objective-C

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

JavaScript

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

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
1
public static HashMap<String, Object> createAdObject(String name, String adId, Long position, Double length);
Copied!
Example
1
HashMap<String, Object> adInfo = Media.createAdObject("ad-name", "ad-id", 1L, 15D);
Copied!
Returns a map that contains information about the ad.

Swift

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

Objective-C

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

Swift

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

Objective-C

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

JavaScript

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

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
1
public static HashMap<String, Object> createChapterObject(String name,
2
Long position,
3
Double length,
4
Double startTime);
Copied!
Example
1
HashMap<String, Object> chapterInfo = Media.createChapterObject("chapter-name", 1L, 60D, 0D);
Copied!
Returns a map that contains information about the chapter.

Swift

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

Objective-C

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

Swift

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

Objective-C

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

JavaScript

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

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
1
public static HashMap<String, Object> createQoEObject(Long bitrate,
2
Double startupTime,
3
Double fps,
4
Long droppedFrames);
Copied!
Example
1
HashMap<String, Object> qoeInfo = Media.createQoEObject(10000000L, 2D, 23D, 10D);
Copied!
Returns a map that contains information about the quality of experience.

Swift

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

Objective-C

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

Swift

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

Objective-C

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

JavaScript

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

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
1
public static HashMap<String, Object> createStateObject(String stateName);
Copied!
Example
1
HashMap<String, Object> playerStateInfo = Media.createStateObject("fullscreen");
Copied!
Returns a map that contains information about the player state.

Swift

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

Objective-C

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

Swift

Syntax
1
static func createStateObject(withName stateName: String)
Copied!
Example
1
let playerStateObject = ACPMedia.createStateObject(withName: "fullscreen")
Copied!

Objective-C

Syntax
1
+ (NSDictionary* _Nonnull) createStateObjectWithName: (NSString* _Nonnull) stateName;
Copied!
Example
1
NSDictionary *playerStateObject = [ACPMedia createStateObjectWithName: @"fullscreen"];
Copied!

JavaScript

1
let playerStateObject = ACPMedia.createStateObject("fullscreen");
Copied!

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

Java

Syntax
1
public void trackSessionStart(Map<String, Object> mediaInfo, Map<String, String> contextData);
Copied!