Media API reference
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
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.
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.
Syntax
static func createTracker()
Example
let tracker = Media.createTracker() // Use the instance for tracking media.
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.
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.
})
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.
}];
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
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.
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)
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.
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.
}
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.
}];
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})
);
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
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.
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)
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.
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)
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];
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
Returns a map that contains information about the ad break.
Syntax
static func createAdBreakObjectWith(name: String,
position: Int,
startTime: Double) -> [String: Any]?
Example
let adBreakObject = Media.createAdBreakObjectWith(name: "adbreak-name",
position: 1,
startTime: 0)
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.
Syntax
static func createAdBreakObject(withName name: String,
position: Double, tartTime: Double)
Example
let adBreakObject = ACPMedia.createAdBreakObject(withName: "adbreak-name",
position: 1,
startTime: 0)
Syntax
+ (NSDictionary* _Nonnull) createAdBreakObjectWithName: (NSString* _Nonnull) name
position: (double) position
startTime: (double) startTime;
Example
NSDictionary *adBreakObject = [ACPMedia createAdBreakObjectWithName: @"adbreak-name"
position: 1
startTime: 0];
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
Returns a map that contains information about the ad.
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)
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.
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)
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];
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
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.
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)
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.
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)
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];
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 |