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
1
let mediaExtensionVersion = Media.extensionVersion()
Copied!
Objective-C
1
NSString *mediaExtensionVersion = [AEPMobileMedia extensionVersion];
Copied!
Objective-C
1
NSString *mediaExtensionVersion = [ACPMedia extensionVersion];
Copied!
Swift
1
let 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

createTracker

The createTracker function returns the instance of MediaTracker for tracking a media session. The createTracker function with callback as a parameter has been deprecated.
If MobileCore.resetIdentities() is called in the implementation, the existing tracker will stop sending pings. You will need to create a new tracker to generate a new media session.
Syntax
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!

createTracker

Creates a media tracker instance that tracks the playback session. The tracker created should be used to track the streaming content and it sends periodic pings to the media analytics backend.
If MobileCore.resetIdentities() is called in the implementation, the existing tracker will stop sending pings. You will need to create a new tracker to generate a new media session.
Syntax
1
static func createTracker()
Copied!
Examples
Swift
1
let tracker = Media.createTracker() // Use the instance for tracking media.
Copied!
Objective-C
1
id<AEPMediaTracker> tracker;
2
_tracker = [AEPMobileMedia createTracker]; // Use the instance for tracking media.
Copied!

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
1
+(ACPMediaTracker* _Nullable) createTracker;
2
3
4
// Deprecated
5
+(void) createTracker: (void (^ _Nonnull) (ACPMediaTracker* _Nullable)) callback;
Copied!
Examples
Here are examples in Objective-C and Swift:
Objective-C
1
ACPMediaTracker *mediaTracker = [ACPMedia createTracker]; // Use the instance for tracking media.
2
3
4
// Deprecated
5
[ACPMedia createTracker:^(ACPMediaTracker * _Nullable mediaTracker) {
6
// Use the instance for tracking media.
7
}];
Copied!
Swift
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!
JavaScript

createTracker

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 from launch for media tracked with this tracker instance.
String
No
config.downloadedcontent
Creates a tracker instance to track downloaded media. Instead of sending periodic pings, the tracker only sends one ping for the entire content.
Boolean
No
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native

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
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 from launch
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!

createTrackerWithConfig

Creates a media tracker instance based on the configuration to track the playback session.
Syntax
1
static func createTrackerWith(config: [String: Any]?)
Copied!
Examples
Swift
1
var config: [String: Any] = [:]
2
config[MediaConstants.TrackerConfig.CHANNEL] = "custom-channel" // Overrides channel configured from launch
3
config[MediaConstants.TrackerConfig.DOWNLOADED_CONTENT] = true // Creates downloaded content tracker
4
5
let tracker = Media.createTrackerWith(config: config)
Copied!
Objective-C
1
id<AEPMediaTracker> _tracker;
2
NSMutableDictionary* config = [NSMutableDictionary dictionary];
3
4
config[AEPMediaTrackerConfig.CHANNEL] = @"custom-channel"; // Overrides channel configured from launch
5
config[AEPMediaTrackerConfig.DOWNLOADED_CONTENT] = [NSNumber numberWithBool:true]; // Creates downloaded content tracker
6
7
_tracker = [AEPMobileMedia createTrackerWithConfig:config];
Copied!

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
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!
Examples
Here are examples in Objective-C and Swift:
Objective-C
1
NSMutableDictionary* config = [NSMutableDictionary dictionary];
2
config[ACPMediaKeyConfigChannel] = @"custom-channel"; // Override channel configured from launch
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!
Swift
1
var config: [String: Any] = [:]
2
config[ACPMediaKeyConfigChannel] = "custom-channel" // Override channel configured from launch
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!
JavaScript

createTracker

1
var config = new Object();
2
config[ACPMediaConstants.ACPMediaKeyConfigChannel] = "customer-channel"; // Override channel configured from launch
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
Media name
Yes
mediaId
Media unique identifier
Yes
length
Media length
Yes
streamType
Yes
mediaType
Yes
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native

createMediaObject

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!

createMediaObject

Returns a map that contains information about the media.
Syntax
1
static func createMediaObjectWith(name: String,
2
id: String,
3
length: Double,
4
streamType: String,
5
mediaType: MediaType) -> [String: Any]?
Copied!
Example
Swift
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
1
NSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name"
2
id:@"video-id"
3
length:60
4
streamType:AEPMediaStreamType.VOD
5
mediaType:AEPMediaTypeVideo];
Copied!

createMediaObjectWithName

Returns an NSDictionary instance that contains information about the media.
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
Here are examples in Objective-C and Swift:
Objective-C
1
NSDictionary *mediaObject = [ACPMedia createMediaObjectWithName: @"video-name"
2
mediaId: @"video-id"
3
length: 60
4
streamType: ACPMediaStreamTypeVod
5
mediaType: ACPMediaTypeVideo];
Copied!
Swift
1
let mediaObject = ACPMedia.createMediaObject(withName: "video-name", mediaId: "video-id",
2
length: Double(60),
3
streamType: ACPMediaStreamTypeVod,
4
mediaType:ACPMediaType.video)
Copied!
JavaScript

createMediaObject

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

createAdBreakObject

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!

createAdBreakObject

Returns a map that contains information about the ad break.
Syntax
1
static func createAdBreakObjectWith(name: String,
2
position: Int,
3
startTime: Double) -> [String: Any]?
Copied!
Example
Swift
1
let adBreakObject = Media.createAdBreakObjectWith(name: "adbreak-name",
2
position: 1,
3
startTime: 0)
Copied!
Objective-C
1
NSDictionary *adBreakObject = [AEPMobileMedia createAdBreakObjectWith:@"adbreak-name"
2
position:1
3
startTime:0];
Copied!

createAdBreakObjectWithName

Returns an NSDictionary instance that contains information about the ad break.
Syntax
1
+ (NSDictionary* _Nonnull) createAdBreakObjectWithName: (NSString* _Nonnull) name
2
position: (double) position
3
startTime: (double) startTime;
Copied!
Example
Here are examples in Objective-C and Swift:
Objective-C
1
NSDictionary *adBreakObject = [ACPMedia createAdBreakObjectWithName: @"adbreak-name"
2
position: 1
3
startTime: 0];
Copied!
Swift
1
let adBreakObject = ACPMedia.createAdBreakObject(withName: "adbreak-name", position: 1, startTime: 0)
Copied!
JavaScript

createAdBreakObject

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

createAdObject

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!

createAdObject

Returns a map that contains information about the ad.
Syntax
1
static func createAdObjectWith(name: String,
2
id: String,
3
position: Int,
4
length: Double) -> [String: Any]?
Copied!
Example
Swift
1
let adObject = Media.createObjectWith(name: "ad-name",
2
id: "ad-id",
3
position: 0,
4
length: 30)
Copied!
Objective-C
1
NSDictionary *adObject = [AEPMobileMedia createAdObjectWith:@"ad-name"
2
id:@"ad-id"
3
position:0
4
length:30];
Copied!

createAdObjectWithName

Returns an NSDictionary instance that contains information about the ad.
Syntax
1
+ (NSDictionary* _Nonnull) createAdObjectWithName: (NSString* _Nonnull) name
2
adId: (NSString* _Nonnull) adId
3
position: (double) position
4
length: (double) length;
Copied!
Example
Here are examples in Objective-C and Swift:
Objective-C
1
NSDictionary *adObject = [ACPMedia createAdObjectWithName: @"ad-name"
2
adId: @"ad-id"
3
position: 1
4
length: 15];
Copied!
Swift
1
let adObject = ACPMedia.createAdObject(withName: "ad-name", adId: "ad-id", position: 1, length: 15)
Copied!
JavaScript

createAdObject

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

createChapterObject

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!

createChapterObject

Returns a map that contains information about the chapter.
Syntax
1
static func createChapterObjectWith(name: String,
2
position: Int,
3
length: Double,
4
startTime: Double) -> [String: Any]?
Copied!
Example
Swift
1
let chapterObject = Media.createChapterObjectWith(name: "chapter_name",
2
position: 1,
3
length: 60,
4
startTime: 0)
Copied!
Objective-C
1
NSDictionary *chapterObject = [AEPMobileMedia createChapterObjectWith:@"chapter_name"
2
position:1
3
length:60
4
startTime:0];
Copied!

createChapterObjectWithName

Returns an NSDictionary instance that contains information about the chapter.
Syntax
1
+ (NSDictionary* _Nonnull) createChapterObjectWithName: (NSString* _Nonnull) name
2
position: (double) position
3
length: (double) length
4
startTime: (double) startTime;
Copied!
Example
Here are examples in Objective-C and Swift:
Objective-C
1
NSDictionary *chapterObject = [ACPMedia createChapterObjectWithName: @"chapter-name"
2
position: 1
3
length: 60
4
startTime: 0];
Copied!
Swift
1
let chapterObject = ACPMedia.createChapterObject(withName: "chapter-name", position: 1, length: 60, startTime: 0)
Copied!
JavaScript

createChapterObject

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

createQoEObject

Creates an instance of the QoE object.
Variable Name
Description
Required
bitrate
Current bitrate
Yes
startupTime
Startup time
Yes
fps
FPS value
Yes
droppedFrames
Number of dropped frames
Yes
All the QoE values bitrate, startupTime, fps, droppedFrames would be converted to long for reporting purposes.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native

createQoEObject

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!

createQoEObject

Returns a map that contains information about the quality of experience.
Syntax
1
static func createQoEObjectWith(bitrate: Double,
2
startupTime: Double,
3
fps: Double,
4
droppedFrames: Double) -> [String: Any]?
Copied!
Example
Swift
1
let qoeObject = Media.createQoEObjectWith(bitrate: 500000,
2
startupTime: 2,
3
fps: 24,
4
droppedFrames: 10)
Copied!
Objective-C
1
NSDictionary *qoeObject = [AEPMobileMedia createQoEObjectWith:50000
2
startTime:2
3
fps:24
4
droppedFrames:10];