Java
Syntax
Copied to your clipboardpublic static String extensionVersion() {
Example
Copied to your clipboardString mediaExtensionVersion = Media.extensionVersion();
Kotlin
Example
Copied to your clipboardval mediaExtensionVersion = Media.extensionVersion()
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet mediaExtensionVersion = Media.extensionVersion()
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *mediaExtensionVersion = [AEPMobileMedia extensionVersion];
Java
Syntax
Copied to your clipboardpublic static void registerExtension()
Example
Copied to your clipboardMedia.registerExtension();
Kotlin
Example
Copied to your clipboardMedia.registerExtension()
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
Copied to your clipboardpublic static MediaTracker createTracker()
Example
Copied to your clipboardMediaTracker mediaTracker = Media.createTracker(); // Use the instance for tracking media.
Kotlin
Example
Copied to your clipboardval tracker = Media.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.
Swift
Syntax
Copied to your clipboardstatic func createTracker()
Example
Copied to your clipboardlet tracker = Media.createTracker() // Use the instance for tracking media.
Objective-C
Syntax
Copied to your clipboard+ (void) createTracker
Example
Copied to your clipboardid<AEPMediaTracker> tracker;_tracker = [AEPMobileMedia createTracker]; // Use the instance for tracking media.
Java
Syntax
Copied to your clipboardpublic static MediaTracker createTracker(Map<String, Object> config)
Example
Copied to your clipboardHashMap<String, Object> config = new HashMap<String, Object>();config.put(MediaConstants.Config.CHANNEL, "custom-channel"); // Override channel configured in the Data Collection UIconfig.put(MediaConstants.Config.DOWNLOADED_CONTENT, true); // Creates downloaded content trackerMediaTracker mediaTracker = Media.createTracker(config); // Use the instance for tracking media.
Kotlin
Example
Copied to your clipboardval config = mapOf(MediaConstants.Config.CHANNEL to "custom-channel",MediaConstants.Config.DOWNLOADED_CONTENT to true)val mediaTracker = Media.createTracker(config) // Use the instance for tracking media.
Creates a media tracker instance based on the configuration to track the playback session.
Swift
Syntax
Copied to your clipboardstatic func createTrackerWith(config: [String: Any]?)
Example
Copied to your clipboardvar config: [String: Any] = [:]config[MediaConstants.TrackerConfig.CHANNEL] = "custom-channel" // Overrides channel configured in the Data Collection UIconfig[MediaConstants.TrackerConfig.DOWNLOADED_CONTENT] = true // Creates downloaded content trackerlet tracker = Media.createTrackerWith(config: config)
Objective-C
Syntax
Copied to your clipboard+(id<AEPMediaTracker> _Nonnull) createTrackerWithConfig:(NSDictionary<NSString *,id> * _Nullable)
Example
Copied to your clipboardid<AEPMediaTracker> _tracker;NSMutableDictionary* config = [NSMutableDictionary dictionary];config[AEPMediaTrackerConfig.CHANNEL] = @"custom-channel"; // Overrides channel configured in the Data Collection UIconfig[AEPMediaTrackerConfig.DOWNLOADED_CONTENT] = [NSNumber numberWithBool:true]; // Creates downloaded content tracker_tracker = [AEPMobileMedia createTrackerWithConfig:config];
Java
Syntax
Copied to your clipboardpublic static HashMap<String, Object> createMediaObject(String name,String mediaId,Double length,String streamType,MediaType mediaType);
Example
Copied to your clipboardHashMap<String, Object> mediaInfo = Media.createMediaObject("video-name","video-id",60D,MediaConstants.StreamType.VOD,Media.MediaType.Video);
Kotlin
Example
Copied to your clipboardvar 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
Copied to your clipboardstatic func createMediaObjectWith(name: String,id: String,length: Double,streamType: String,mediaType: MediaType) -> [String: Any]?
Example
Copied to your clipboardlet mediaObject = Media.createMediaObjectWith(name: "video-name",id: "videoId",length: 60,streamType: MediaConstants.StreamType.VOD,mediaType: MediaType.Video)
Objective-C
Syntax
Copied to your clipboard+ (NSDictionary<NSString *, id> * _Nullable) createMediaObjectWith:(NSString * _Nonnull) id:(NSString * _Nonnull) length:(double) streamType:(NSString * _Nonnull) mediaType:(enum AEPMediaType)
Example
Copied to your clipboardNSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name"id:@"video-id"length:60streamType:AEPMediaStreamType.VODmediaType:AEPMediaTypeVideo];
Java
Syntax
Copied to your clipboardpublic static HashMap<String, Object> createAdBreakObject(String name, Long position, Double startTime);
Example
Copied to your clipboardHashMap<String, Object> adBreakObject = Media.createAdBreakObject("adbreak-name", 1L, 0D);
Kotlin
Example
Copied to your clipboardval adBreakObject = Media.createAdBreakObject("adbreak-name", 1L, 0D)
Returns a map that contains information about the ad break.
Swift
Syntax
Copied to your clipboardstatic func createAdBreakObjectWith(name: String,position: Int,startTime: Double) -> [String: Any]?
Example
Copied to your clipboardlet adBreakObject = Media.createAdBreakObjectWith(name: "adbreak-name",position: 1,startTime: 0)
Objective-C
Syntax
Copied to your clipboard+ (NSDictionary <NSString *, id> * _Nullable) createAdBreakObjectWith:(NSString * _Nonnull)position:(NSInteger) startTime:(double)
Example
Copied to your clipboardNSDictionary *adBreakObject = [AEPMobileMedia createAdBreakObjectWith:@"adbreak-name"position:1startTime:0];
Java
Syntax
Copied to your clipboardpublic static HashMap<String, Object> createAdObject(String name, String adId, Long position, Double length);
Example
Copied to your clipboardHashMap<String, Object> adInfo = Media.createAdObject("ad-name", "ad-id", 1L, 15D);
Kotlin
Example
Copied to your clipboardval adInfo = Media.createAdObject("ad-name", "ad-id", 1L, 15D)
Returns a map that contains information about the ad.
Swift
Syntax
Copied to your clipboardstatic func createAdObjectWith(name: String,id: String,position: Int,length: Double) -> [String: Any]?
Example
Copied to your clipboardlet adObject = Media.createObjectWith(name: "ad-name",id: "ad-id",position: 0,length: 30)
Objective-C
Syntax
Copied to your clipboard+ (NSDictionary <NSString *, id> * _Nullable) createAdObjectWith: (NSString * _Nonnullid:(NSString * _Nonnull)position:(NSInteger)length:(double)
Example
Copied to your clipboardNSDictionary *adObject = [AEPMobileMedia createAdObjectWith:@"ad-name"id:@"ad-id"position:0length:30];
Java
Syntax
Copied to your clipboardpublic static HashMap<String, Object> createChapterObject(String name,Long position,Double length,Double startTime);
Example
Copied to your clipboardHashMap<String, Object> chapterInfo = Media.createChapterObject("chapter-name", 1L, 60D, 0D);
Kotlin
Example
Copied to your clipboardval chapterInfo = Media.createChapterObject("chapter-name", 1L, 60D, 0D)
Returns a map that contains information about the chapter.
Swift
Syntax
Copied to your clipboardstatic func createChapterObjectWith(name: String,position: Int,length: Double,startTime: Double) -> [String: Any]?
Example
Copied to your clipboardlet chapterObject = Media.createChapterObjectWith(name: "chapter_name",position: 1,length: 60,startTime: 0)
Objective-C
Syntax
Copied to your clipboard+ (NSDictionary <NSString *, id> * _Nullable) createChapterObjectWith:(NSString * _Nonnull)position:(NSInteger)length:(double)startTime:(double)
Example
Copied to your clipboardNSDictionary *chapterObject = [AEPMobileMedia createChapterObjectWith:@"chapter_name"position:1length:60startTime:0];
Java
Syntax
Copied to your clipboardpublic static HashMap<String, Object> createQoEObject(Long bitrate,Double startupTime,Double fps,Long droppedFrames);
Example
Copied to your clipboardHashMap<String, Object> qoeInfo = Media.createQoEObject(10000000L, 2D, 23D, 10D);
Kotlin
Example
Copied to your clipboardval qoeInfo = Media.createQoEObject(10000000L, 2D, 23D, 10D)
Returns a map that contains information about the quality of experience.
Swift
Syntax
Copied to your clipboardstatic func createQoEObjectWith(bitrate: Double,startupTime: Double,fps: Double,droppedFrames: Double) -> [String: Any]?
Example
Copied to your clipboardlet qoeObject = Media.createQoEObjectWith(bitrate: 500000,startupTime: 2,fps: 24,droppedFrames: 10)
Objective-C
Syntax
Copied to your clipboard+ (NSDictionary <NSString *, id> * _Nullable) createQoEObjectWith:(double)startTime:(double)fps:(double)droppedFrames:(double)
Example
Copied to your clipboardNSDictionary *qoeObject = [AEPMobileMedia createQoEObjectWith:500000startTime:2fps:24droppedFrames:10];
Java
Syntax
Copied to your clipboardpublic static HashMap<String, Object> createStateObject(String stateName);
Example
Copied to your clipboardHashMap<String, Object> playerStateInfo = Media.createStateObject("fullscreen");
Kotlin
Example
Copied to your clipboardval playerStateInfo = Media.createStateObject("fullscreen")
Returns a map that contains information about the player state.
Swift
Syntax
Copied to your clipboardstatic func createStateObjectWith(stateName: String) -> [String: Any]
Example
Copied to your clipboardlet fullScreenState = Media.createStateObjectWith(stateName: "fullscreen")
Objective-C
Syntax
Copied to your clipboard+ (NSDictionary <NSString *, id> * _Nullable) createStateObjectWith:(NSString * _Nonnull)
Example
Copied to your clipboardNSDictionary* fullScreenState = [AEPMobileMedia createStateObjectWith:AEPMediaPlayerState.FULLSCREEN]
Java
Syntax
Copied to your clipboardpublic void trackSessionStart(Map<String, Object> mediaInfo, Map<String, String> contextData);
Example
Copied to your clipboardHashMap<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 keysmediaMetadata.put("isUserLoggedIn", "false");mediaMetadata.put("tvStation", "Sample TV Station");_tracker.trackSessionStart(mediaInfo, mediaMetadata);
Kotlin
Example
Copied to your clipboardval mediaObject = Media.createMediaObject("media-name","media-id",60.0,MediaConstants.StreamType.VOD,Media.MediaType.Video)val mediaMetadata = HashMap<String, String>()// Standard metadata keys provided by adobe.mediaMetadata[MediaConstants.VideoMetadataKeys.EPISODE] = "Sample Episode"mediaMetadata[MediaConstants.VideoMetadataKeys.SHOW] = "Sample Show"// Custom metadata keysmediaMetadata["isUserLoggedIn"] = "false"mediaMetadata["tvStation"] = "Sample TV Station"tracker.trackSessionStart(mediaInfo, mediaMetadata)
Swift
Syntax
Copied to your clipboardpublic func trackSessionStart(info: [String: Any], metadata: [String: String]? = nil)
Example
Copied to your clipboardlet mediaObject = Media.createMediaObjectWith(name: "video-name", id: "videoId", length: 60, streamType: MediaConstants.StreamType.VOD, mediaType: MediaType.Video)var videoMetadata: [String: String] = [:]// Sample implementation for using video standard metadata keysvideoMetadata[MediaConstants.VideoMetadataKeys.SHOW] = "Sample show"videoMetadata[MediaConstants.VideoMetadataKeys.SEASON] = "Sample season"// Sample implementation for using custom metadata keysvideoMetadata["isUserLoggedIn"] = "false"videoMetadata["tvStation"] = "Sample TV station"tracker.trackSessionStart(info: mediaObject, metadata: videoMetadata)
Objective-C
Syntax
Copied to your clipboard+ (void) trackSessionStart:(NSDictionary<NSString *,id> * _Nonnull) metadata:(NSDictionary<NSString *,NSString *> * _Nullable)
Example
Copied to your clipboardNSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name" id:@"video-id" length:60 streamType:AEPMediaStreamType.VOD mediaType:AEPMediaTypeVideo];NSMutableDictionary *videoMetadata = [[NSMutableDictionary alloc] init];// Sample implementation for using standard video metadata keys[videoMetadata setObject:@"Sample show" forKey:AEPVideoMetadataKeys.SHOW];[videoMetadata setObject:@"Sample Season" forKey:AEPVideoMetadataKeys.SEASON];// Sample implementation for using custom metadata keys[videoMetadata setObject:@"false" forKey:@"isUserLoggedIn"];[videoMetadata setObject:@"Sample TV station" forKey:@"tvStation"];[_tracker trackSessionStart:mediaObject metadata:videoMetadata];
Java
Syntax
Copied to your clipboardpublic void trackPlay();
Example
Copied to your clipboardtracker.trackPlay();
Kotlin
Example
Copied to your clipboardtracker.trackPlay();
Swift
Syntax
Copied to your clipboardfunc trackPlay()
Example
Copied to your clipboardtracker.trackPlay()
Objective-C
Syntax
Copied to your clipboard- (void) trackPlay;
Example
Copied to your clipboard[_tracker trackPlay];
Java
Syntax
Copied to your clipboardpublic void trackPause();
Example
Copied to your clipboardtracker.trackPause();
Kotlin
Example
Copied to your clipboardtracker.trackPause();
Swift
Syntax
Copied to your clipboardfunc trackPause()
Example
Copied to your clipboardtracker.trackPause()
Objective-C
Syntax
Copied to your clipboard- (void) trackPause
Example
Copied to your clipboard[_tracker trackPause];
Java
Syntax
Copied to your clipboardpublic void trackComplete();
Example
Copied to your clipboardtracker.trackComplete();
Kotlin
Example
Copied to your clipboardtracker.trackComplete();
Swift
Syntax
Copied to your clipboardfunc trackComplete()
Example
Copied to your clipboardtracker.trackComplete()
Objective-C
Syntax
Copied to your clipboard- (void) trackComplete
Example
Copied to your clipboard[_tracker trackComplete];
Java
Syntax
Copied to your clipboardpublic void trackSessionEnd();
Example
Copied to your clipboardtracker.trackSessionEnd();
Kotlin
Example
Copied to your clipboardtracker.trackSessionEnd();
Swift
Syntax
Copied to your clipboardfunc trackSessionEnd()
Example
Copied to your clipboardtracker.trackSessionEnd()
Objective-C
Syntax
Copied to your clipboard- (void) trackSessionEnd
Example
Copied to your clipboard[_tracker trackSessionEnd];
Java
Syntax
Copied to your clipboardpublic void trackError(String errorId);
Example
Copied to your clipboardtracker.trackError("errorId");
Kotlin
Example
Copied to your clipboardtracker.trackError("errorId");
Swift
Syntax
Copied to your clipboardfunc trackError(errorId: String)
Example
Copied to your clipboardtracker.trackError(errorId: "errorId")
Objective-C
Syntax
Copied to your clipboard- (void) trackError:(NSString * _Nonnull)
Example
Copied to your clipboard[_tracker trackError:@"errorId"];
Java
Syntax
Copied to your clipboardpublic void trackEvent(Media.Event event,Map<String, Object> info,Map<String, String> data);
Examples
Tracking player states
Copied to your clipboard// StateStartHashMap<String, Object> stateObject = Media.createStateObject("fullscreen");_tracker.trackEvent(Media.Event.StateStart, stateObject, null);// StateEndHashMap<String, Object> stateObject = Media.createStateObject("fullscreen");_tracker.trackEvent(Media.Event.StateEnd, stateObject, null);
Tracking ad breaks
Copied to your clipboard// AdBreakStartHashMap<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
Copied to your clipboard// AdStartHashMap<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 keysadMetadata.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
Copied to your clipboard// ChapterStartHashMap<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
Copied to your clipboard// 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
Copied to your clipboard// 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_tracker.trackEvent(Media.Event.BitrateChange, null, null);
Kotlin
Examples
Tracking player states
Copied to your clipboard// StateStartval stateObject = Media.createStateObject("fullscreen")tracker.trackEvent(Media.Event.StateStart, stateObject, null)// StateEndval stateObject = Media.createStateObject("fullscreen")tracker.trackEvent(Media.Event.StateEnd, stateObject, null)`
Tracking ad breaks
Copied to your clipboard// AdBreakStartval adBreakObject = Media.createAdBreakObject("adbreak-name", 1L, 0.0)tracker.trackEvent(Media.Event.AdBreakStart, adBreakObject, null)// AdBreakCompletetracker.trackEvent(Media.Event.AdBreakComplete, null, null)
Tracking ads
Copied to your clipboard//AdStartval adObject = Media.createAdObject("ad-name", "ad-id", 1L, 15.0)val adMetadata = HashMap<String, String>()// Standard metadata keys provided by adobe.adMetadata[MediaConstants.AdMetadataKeys.ADVERTISER] = "Sample Advertiser"adMetadata[MediaConstants.AdMetadataKeys.CAMPAIGN_ID] = "Sample Campaign"// Custom metadata keysadMetadata["affiliate"] = "Sample affiliate"tracker.trackEvent(Media.Event.AdStart, adObject, adMetadata)// AdCompletetracker.trackEvent(Media.Event.AdComplete, null, null)// AdSkiptracker.trackEvent(Media.Event.AdSkip, null, null)
Tracking chapters
Copied to your clipboard// ChapterStartval chapterObject = Media.createChapterObject("chapter-name", 1L, 60.0, 0.0)val chapterMetadata = HashMap<String, String>()chapterMetadata["segmentType"] = "Sample segment type"tracker.trackEvent(Media.Event.ChapterStart, chapterObject, chapterMetadata)// ChapterCompletetracker.trackEvent(Media.Event.ChapterComplete, null, null)// ChapterSkiptracker.trackEvent(Media.Event.ChapterSkip, null, null)
Tracking playback events
Copied to your clipboard// BufferStarttracker.trackEvent(Media.Event.BufferStart, null, null)// BufferCompletetracker.trackEvent(Media.Event.BufferComplete, null, null)// SeekStarttracker.trackEvent(Media.Event.SeekStart, null, null)// SeekCompletetracker.trackEvent(Media.Event.SeekComplete, null, null)
Tracking bitrate changes
Copied to your clipboard// If the new bitrate value is available provide it to the tracker.val qoeObject = Media.createQoEObject(2000000L, 2D, 25D, 10D)tracker.updateQoEObject(qoeObject)// Bitrate changetracker.trackEvent(Media.Event.BitrateChange, null, null)
Swift
Syntax
Copied to your clipboardfunc trackEvent(event: MediaEvent, info: [String: Any]?, metadata: [String: String]?)
Examples
Tracking player states
Copied to your clipboard// StateStartlet fullScreenState = Media.createStateObjectWith(stateName: MediaConstants.PlayerState.FULLSCREEN)tracker.trackEvent(event: MediaEvent.StateStart, info: fullScreenState, metadata: nil)// StateEndlet fullScreenState = Media.createStateObjectWith(stateName: MediaConstants.PlayerState.FULLSCREEN)tracker.trackEvent(event: MediaEvent.StateEnd, info: fullScreenState, metadata: nil)
Tracking ad breaks
Copied to your clipboard// AdBreakStartlet adBreakObject = Media.createAdBreakObjectWith(name: "adbreak-name", position: 1, startTime: 0)tracker.trackEvent(event: MediaEvent.AdBreakStart, info: adBreakObject, metadata: nil)// AdBreakCompletetracker.trackEvent(event: MediaEvent.AdBreakComplete, info: nil, metadata: nil)
Tracking ads
Copied to your clipboard// AdStartlet adObject = Media.createObjectWith(name: "adbreak-name", id: "ad-id", position: 0, length: 30)// Standard metadata keys provided by adobe.var adMetadata: [String: String] = [:]adMetadata[MediaConstants.AdMetadataKeys.ADVERTISER] = "Sample Advertiser"adMetadata[MediaConstants.AdMetadataKeys.CAMPAIGN_ID] = "Sample Campaign"// Custom metadata keysadMetadata["affiliate"] = "Sample affiliate"tracker.trackEvent(event: MediaEvent.AdStart, info: adObject, metadata: adMetadata)// AdCompletetracker.trackEvent(event: MediaEvent.AdComplete, info: nil, metadata: nil)// AdSkiptracker.trackEvent(event: MediaEvent.AdSkip, info: nil, metadata: nil)
Tracking chapters
Copied to your clipboard// ChapterStartlet chapterObject = Media.createChapterObjectWith(name: "chapter_name", position: 1, length: 60, startTime: 0)let chapterDictionary = ["segmentType": "Sample segment type"]tracker.trackEvent(event: MediaEvent.ChapterStart, info: chapterObject, metadata: chapterDictionary)// ChapterCompletetracker.trackEvent(event: MediaEvent.ChapterComplete, info: nil, metadata: nil)// ChapterSkiptracker.trackEvent(event: MediaEvent.ChapterSkip, info: nil, metadata: nil)
Tracking playback events
Copied to your clipboard// BufferStarttracker.trackEvent(event: MediaEvent.BufferStart, info: nil, metadata: nil)// BufferCompletetracker.trackEvent(event: MediaEvent.BufferComplete, info: nil, metadata: nil)// SeekStarttracker.trackEvent(event: MediaEvent.SeekStart, info: nil, metadata: nil)// SeekCompletetracker.trackEvent(event: MediaEvent.SeekComplete, info: nil, metadata: nil)
Tracking bitrate change
Copied to your clipboard// If the new bitrate value is available provide it to the tracker.let qoeObject = Media.createQoEObjectWith(bitrate: 500000, startupTime: 2, fps: 24, droppedFrames: 10)tracker.updateQoEObject(qoeObject)// Bitrate changetracker.trackEvent(event: MediaEvent.BitrateChange, info: nil, metadata: nil)
Objective-C
Syntax
Copied to your clipboard- (void) trackEvent:(enum AEPMediaEvent) info:(NSDictionary<NSString *,id> * _Nullable) metadata:(NSDictionary<NSString *,NSString *> * _Nullable)
Examples
Tracking player states
Copied to your clipboard// StateStartNSDictionary* fullScreenState = [AEPMobileMedia createStateObjectWith:AEPMediaPlayerState.FULLSCREEN];[_tracker trackEvent:AEPMediaEventStateStart info:fullScreenState metadata:nil];// StateEndNSDictionary* fullScreenState = [AEPMobileMedia createStateObjectWith:AEPMediaPlayerState.FULLSCREEN];[_tracker trackEvent:AEPMediaEventStateEnd info:fullScreenState metadata:nil];
Tracking ad breaks
Copied to your clipboard// AdBreakStartNSDictionary *adBreakObject = [AEPMobileMedia createAdBreakObjectWith:@"adbreak-name" position:1 startTime:0];[_tracker trackEvent:AEPMediaEventAdBreakStart info:adBreakObject metadata:nil];// AdBreakComplete[_tracker trackEvent:AEPMediaEventAdBreakComplete info:nil metadata:nil];
Tracking ads
Copied to your clipboard// AdStartNSDictionary *adObject = [AEPMobileMedia createAdObjectWith:@"ad-name" id:@"ad-id" position:0 length:30];NSMutableDictionary* adMetadata = [[NSMutableDictionary alloc] init];// Standard metadata keys provided by adobe.[adMetadata setObject:@"Sample Advertiser" forKey:AEPAdMetadataKeys.ADVERTISER];[adMetadata setObject:@"Sample Campaign" forKey:AEPAdMetadataKeys.CAMPAIGN_ID];// Custom metadata keys[adMetadata setObject:@"Sample affiliate" forKey:@"affiliate"];[_tracker trackEvent:AEPMediaEventAdStart info:adObject metadata:adMetadata];// AdComplete[_tracker trackEvent:AEPMediaEventAdComplete info:nil metadata:nil];// AdSkip[_tracker trackEvent:AEPMediaEventAdSkip info:nil metadata:nil];
Tracking chapters
Copied to your clipboard// ChapterStartNSDictionary *chapterObject = [AEPMobileMedia createChapterObjectWith:@"chapter_name" position:1 length:60 startTime:0];NSMutableDictionary *chapterMetadata = [[NSMutableDictionary alloc] init];[chapterMetadata setObject:@"Sample segment type" forKey:@"segmentType"];[_tracker trackEvent:AEPMediaEventChapterStart info:chapterObject metadata:chapterMetadata];// ChapterComplete[_tracker trackEvent:AEPMediaEventChapterComplete info:nil metadata:nil];// ChapterSkip[_tracker trackEvent:AEPMediaEventChapterSkip info:nil metadata:nil];
Tracking playback events
Copied to your clipboard// BufferStart[_tracker trackEvent:AEPMediaEventBufferStart info:nil metadata:nil];// BufferComplete[_tracker trackEvent:AEPMediaEventBufferComplete info:nil metadata:nil];// SeekStart[_tracker trackEvent:AEPMediaEventSeekStart info:nil metadata:nil];// SeekComplete[_tracker trackEvent:AEPMediaEventSeekComplete info:nil metadata:nil];
Tracking bitrate change
Copied to your clipboard// If the new bitrate value is available provide it to the tracker.NSDictionary *qoeObject = [AEPMobileMedia createQoEObjectWith:50000 startTime:2 fps:24 droppedFrames:10];// Bitrate change[_tracker trackEvent:AEPMediaEventBitrateChange info:nil metadata:nil];
Java
Syntax
Copied to your clipboardpublic void updateCurrentPlayhead(double time);
Example
Copied to your clipboardtracker.updateCurrentPlayhead(1);
Live streaming example
Copied to your clipboard//Calculation for number of seconds since midnight UTC of the daydouble timeFromMidnightInSecond = (System.currentTimeMillis()/1000) % 86400;tracker.updateCurrentPlayhead(timeFromMidnightInSecond);
Kotlin
Example
Copied to your clipboardtracker.updateCurrentPlayhead(1);
Live streaming example
Copied to your clipboardval timeFromMidnightInSecond = (System.currentTimeMillis() / 1000 % 86400).toDouble()tracker.updateCurrentPlayhead(timeFromMidnightInSecond);}
Swift
Syntax
Copied to your clipboardfunc updateCurrentPlayhead(time: Double)
Example
Copied to your clipboardtracker.updateCurrentPlayhead(1);
Live streaming example
Copied to your clipboard//Calculation for number of seconds since midnight UTC of the daylet secondsSince1970: TimeInterval = (Date().timeIntervalSince1970)let timeFromMidnightInSecond = secondsSince1970.truncatingRemainder(dividingBy: 86400)tracker.updateCurrentPlayhead(time: timeFromMidnightInSecond)
Objective-C
Syntax
Copied to your clipboard- (void) updateCurrentPlayhead:(double)
Example
Copied to your clipboard[_tracker updateCurrentPlayhead:1];
Java
Syntax
Copied to your clipboardpublic void updateQoEObject(Map<String, Object> qoeObject);
Example
Copied to your clipboardHashMap<String, Object> qoeObject = Media.createQoEObject(1000000L, 2D, 25D, 10D);tracker.updateQoEObject(qoeObject);
Kotlin
Example
Copied to your clipboardval qoeObject = Media.createQoEObject(1000000L, 2D, 25D, 10D)tracker.updateQoEObject(qoeObject)
Swift
Syntax
Copied to your clipboardfunc updateQoEObject(qoe: [String: Any])
Example
Copied to your clipboardlet qoeObject = Media.createQoEObjectWith(bitrate: 500000, startupTime: 2, fps: 24, droppedFrames: 10)tracker.updateQoEObject(qoe: qoeObject)
Objective-C
Syntax
Copied to your clipboard- (void) updateQoEObject:(NSDictionary<NSString *,id> * _Nonnull)
Example
Copied to your clipboardNSDictionary *qoeObject = [AEPMobileMedia createQoEObjectWith:50000 startTime:2 fps:24 droppedFrames:10][_tracker updateQoEObject:qoeObject];
Copied to your clipboardpublic class Media {public enum MediaType {/*** Constant defining media type for Video streams*/Video,/*** Constant defining media type for Audio streams*/Audio}}
Copied to your clipboard@objc(AEPMediaType)public enum MediaType: Int, RawRepresentable {//Constant defining media type for Video streamscase Audio//Constant defining media type for Audio streamscase Video}
Example
Swift
Copied to your clipboardvar mediaObject = Media.createMediaObjectWith(name: "video-name",id: "videoId",length: "60",streamType: MediaConstants.StreamType.VOD,mediaType: MediaType.Video)
Objective-C
Copied to your clipboardNSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name"id:@"video-id"length:60 streamType:AEPMediaStreamType.VOD mediaType:AEPMediaTypeVideo];
Copied to your clipboardpublic 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";}}
Copied to your clipboardpublic class MediaConstants: NSObject {@objc(AEPMediaStreamType)public class StreamType: NSObject {// Constant defining stream type for VOD streams.public static let VOD = "vod"// Constant defining stream type for Live streams.public static let LIVE = "live"// Constant defining stream type for Linear streams.public static let LINEAR = "linear"// Constant defining stream type for Podcast streams.public static let PODCAST = "podcast"// Constant defining stream type for Audiobook streams.public static let AUDIOBOOK = "audiobook"// Constant defining stream type for AOD streams.public static let AOD = "aod"}}
Example
Swift
Copied to your clipboardvar mediaObject = Media.createMediaObjectWith(name: "video-name",id: "videoId",length: "60",streamType: MediaConstants.StreamType.VOD,mediaType: MediaType.Video)
Objective-C
Copied to your clipboardNSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name"id:@"video-id"length:60streamType:AEPMediaStreamType.VODmediaType:AEPMediaTypeVideo];
Copied to your clipboardpublic 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";}}
Copied to your clipboardpublic class MediaConstants: NSObject {@objc(AEPVideoMetadataKeys)public class VideoMetadataKeys: NSObject {public static let SHOW = "a.media.show"public static let SEASON = "a.media.season"public static let EPISODE = "a.media.episode"public static let ASSET_ID = "a.media.asset"public static let GENRE = "a.media.genre"public static let FIRST_AIR_DATE = "a.media.airDate"public static let FIRST_DIGITAL_DATE = "a.media.digitalDate"public static let RATING = "a.media.rating"public static let ORIGINATOR = "a.media.originator"public static let NETWORK = "a.media.network"public static let SHOW_TYPE = "a.media.type"public static let AD_LOAD = "a.media.adLoad"public static let MVPD = "a.media.pass.mvpd"public static let AUTHORIZED = "a.media.pass.auth"public static let DAY_PART = "a.media.dayPart"public static let FEED = "a.media.feed"public static let STREAM_FORMAT = "a.media.format"}}
Example
Swift
Copied to your clipboardvar mediaObject = Media.createMediaObjectWith(name: "video-name", id: "videoId", length: "60", streamType: MediaConstants.StreamType.VOD, mediaType: MediaType.Video)var videoMetadata: [String: String] = [:]// Standard Video MetadatavideoMetadata[MediaConstants.VideoMetadataKeys.SHOW] = "Sample show"videoMetadata[MediaConstants.VideoMetadataKeys.SEASON] = "Sample season"tracker.trackSessionStart(info: mediaObject, metadata: videoMetadata)
Objective-C
Copied to your clipboardNSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name" id:@"video-id" length:60 streamType:AEPMediaStreamType.VOD mediaType:AEPMediaTypeVideo];NSMutableDictionary *videoMetadata = [[NSMutableDictionary alloc] init];// Standard Video Metadata[videoMetadata setObject:@"Sample show" forKey:AEPVideoMetadataKeys.SHOW];[videoMetadata setObject:@"Sample Season" forKey:AEPVideoMetadataKeys.SEASON];[_tracker trackSessionStart:mediaObject metadata:videoMetadata];
Copied to your clipboardpublic 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";}}
Copied to your clipboardpublic class MediaConstants: NSObject {@objc(AEPAudioMetadataKeys)public class AudioMetadataKeys: NSObject {public static let ARTIST = "a.media.artist"public static let ALBUM = "a.media.album"public static let LABEL = "a.media.label"public static let AUTHOR = "a.media.author"public static let STATION = "a.media.station"public static let PUBLISHER = "a.media.publisher"}}
Example
Swift
Copied to your clipboardvar audioObject = Media.createMediaObjectWith(name: "audio-name", id: "audioId", length: 30, streamType: MediaConstants.StreamType.AOD, mediaType: MediaType.AUDIO)var audioMetadata: [String: String] = [:]// Standard Audio MetadataaudioMetadata[MediaConstants.AudioMetadataKeys.ARTIST] = "Sample artist"audioMetadata[MediaConstants.AudioMetadataKeys.ALBUM] = "Sample album"tracker.trackSessionStart(info: audioObject, metadata: audioMetadata)
Objective-C
Copied to your clipboardNSDictionary *audioObject = [AEPMobileMedia createMediaObjectWith:@"audio-name" id:@"audioid" length:30 streamType:AEPMediaStreamType.AOD mediaType:AEPMediaTypeAudio];NSMutableDictionary *audioMetadata = [[NSMutableDictionary alloc] init];// Standard Audio Metadata[audioMetadata setObject:@"Sample artist" forKey:AEPAudioMetadataKeys.ARTIST];[audioMetadata setObject:@"Sample album" forKey:AEPAudioMetadataKeys.ALBUM];[_tracker trackSessionStart:audioObject metadata:audioMetadata];
Copied to your clipboardpublic 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";}}
Copied to your clipboardpublic class MediaConstants: NSObject {@objc(AEPAdMetadataKeys)public class AdMetadataKeys: NSObject {public static let ADVERTISER = "a.media.ad.advertiser"public static let CAMPAIGN_ID = "a.media.ad.campaign"public static let CREATIVE_ID = "a.media.ad.creative"public static let PLACEMENT_ID = "a.media.ad.placement"public static let SITE_ID = "a.media.ad.site"public static let CREATIVE_URL = "a.media.ad.creativeURL"}}
Example
Swift
Copied to your clipboardlet adObject = Media.createObjectWith(name: "adbreak-name", id: "ad-id", position: 0, length: 30)var adMetadata: [String: String] = [:]// Standard Ad MetadataadMetadata[MediaConstants.AdMetadataKeys.ADVERTISER] = "Sample Advertiser"adMetadata[MediaConstants.AdMetadataKeys.CAMPAIGN_ID] = "Sample Campaign"tracker.trackEvent(event: MediaEvent.AdStart, info: adObject, metadata: adMetadata)
Objective-C
Copied to your clipboardNSDictionary *adObject = [AEPMobileMedia createAdObjectWith:@"ad-name" id:@"ad-id" position:0 length:30];NSMutableDictionary *adMetadata = [[NSMutableDictionary alloc] init];// Standard Ad Metadata[adMetadata setObject:@"Sample Advertiser" forKey:AEPAdMetadataKeys.ADVERTISER];[adMetadata setObject:@"Sample Campaign" forKey:AEPAdMetadataKeys.CAMPAIGN_ID];[_tracker trackEvent:AEPMediaEventAdStart info:adObject metadata:adMetadata];
Copied to your clipboardpublic class MediaConstants {public static final class PlayerState {public static final String FULLSCREEN = "fullscreen";public static final String PICTURE_IN_PICTURE = "pictureInPicture";public static final String CLOSED_CAPTION = "closedCaptioning";public static final String IN_FOCUS = "inFocus";public static final String MUTE = "mute";}}
Copied to your clipboardpublic class MediaConstants: NSObject {@objc(AEPMediaPlayerState)public class PlayerState: NSObject {public static let FULLSCREEN = "fullscreen"public static let PICTURE_IN_PICTURE = "pictureInPicture"public static let CLOSED_CAPTION = "closedCaptioning"public static let IN_FOCUS = "inFocus"public static let MUTE = "mute"}}
Example
Swift
Copied to your clipboardlet inFocusState = Media.createStateObjectWith(stateName: MediaConstants.PlayerState.IN_FOCUS)tracker.trackEvent(event: MediaEvent.StateStart, info: inFocusState, metadata: nil)
Objective-C
Copied to your clipboardNSDictionary* inFocusState = [AEPMobileMedia createStateObjectWith:AEPMediaPlayerState.IN_FOCUS];[_tracker trackEvent:AEPMediaEventStateStart info:muteState metadata:nil];
Copied to your clipboardpublic 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,/*** Constant defining event type for State start*/StateStart,/*** Constant defining event type for State end*/StateEnd}}
Copied to your clipboard@objc(AEPMediaEvent)public enum MediaEvent: Int, RawRepresentable {// event type for AdBreak startcase AdBreakStart// event type for AdBreak Completecase AdBreakComplete// event type for Ad Startcase AdStart// event type for Ad Completecase AdComplete// event type for Ad Skipcase AdSkip// event type for Chapter Startcase ChapterStart// event type for Chapter Completecase ChapterComplete// event type for Chapter Skipcase ChapterSkip// event type for Seek Startcase SeekStart// event type for Seek Completecase SeekComplete// event type for Buffer Startcase BufferStart// event type for Buffer Completecase BufferComplete// event type for change in Bitratecase BitrateChange// event type for Player State Startcase StateStart// event type for Player State Endcase StateEnd}
Example
Swift
Copied to your clipboardtracker.trackEvent(event: MediaEvent.BitrateChange, info: nil, metadata: nil)
Objective-C
Copied to your clipboard[_tracker trackEvent:AEPMediaEventBitrateChange info:nil metadata:nil];
Java
Syntax
Copied to your clipboardpublic 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
Copied to your clipboardHashMap<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);_tracker.trackSessionStart(mediaObject, null);
Swift
Syntax
Copied to your clipboardpublic class MediaConstants: NSObject {@objc(AEPMediaObjectKey)public class MediaObjectKey: NSObject {public static let RESUMED = "media.resumed"}}
Example
Copied to your clipboardvar mediaObject = Media.createMediaObjectWith(name: "video-name", id: "videoId", length: "60", streamType: MediaConstants.StreamType.VOD, mediaType: MediaType.Video)mediaObject[MediaConstants.MediaObjectKey.RESUMED] = truetracker.trackSessionStart(info: mediaObject, metadata: nil)
Objective-C
Syntax
Copied to your clipboard@interface AEPMediaObjectKey : NSObject+ (NSString * _Nonnull)RESUMED
Example
Copied to your clipboardNSDictionary *mediaObject = [AEPMobileMedia createMediaObjectWith:@"video-name" id:@"video-id" length:60 streamType:AEPMediaStreamType.VOD mediaType:AEPMediaTypeVideo];// Attach media resumed information.NSMutableDictionary *obj = [mediaObject mutableCopy];[obj setObject:@YES forKey:AEPMediaObjectKey.RESUMED];[_tracker trackSessionStart:obj metadata:nil];