Skip to content

Latest commit

 

History

History
828 lines (590 loc) · 21.7 KB

api-reference.md

File metadata and controls

828 lines (590 loc) · 21.7 KB

Adobe Streaming Media for Edge Network extension - Android

Prerequisites

Refer to the Getting Started Guide

API reference

APIs
extensionVersion
registerExtensions
createTracker
createTrackerWithConfig
createMediaObject
createAdBreakObject
createAdObject
createChapterObject
createQoEObject
createStateObject

Media Tracker API reference

APIs
trackSessionStart
trackPlay
trackPause
trackComplete
trackSessionEnd
trackError
trackEvent
updateCurrentPlayhead
updateQoEObject

extensionVersion

The extensionVersion() API returns the version of the Media for Edge Network extension that is used to register with the Mobile Core extension.

Syntax

public static String extensionVersion() {

Example

Java
String mediaExtensionVersion = Media.extensionVersion();
Kotlin
val mediaExtensionVersion = Media.extensionVersion()

EXTENSION

Represents a reference to MediaExtension.class that can be used to register with MobileCore via its registerExtensions api.

Syntax

public static final Class<? extends Extension> EXTENSION = MediaExtension.class;

registerExtensions

Refer MobileCore registerExtensions API.

Example

Java
MobileCore.registerExtensions(Arrays.asList(Media.EXTENSION, ...), new AdobeCallback<Object>() {
    // implement completion callback
});
Kotlin
MobileCore.registerExtensions(listOf(Media.EXTENSION, ...)){
    // implement completion callback
}

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.

Syntax

public static MediaTracker createTracker()

Example

Java
MediaTracker tracker = Media.createTracker()
Kotlin
val tracker = Media.createTracker()

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.mainpinginterval Overwrites the default main content tracking interval (in seconds). The value should be in the allowed range [10-50] seconds. The default value is 10 seconds. Int No
config.adpinginterval Overwrites the default ad content tracking interval (in seconds). The value should be in the allowed range [1-10] seconds. The default value is 10 seconds. Int No

Syntax

public static MediaTracker createTracker(Map<String, Object> config)

Example

Java
HashMap<String, Object> config = new HashMap<String, Object>();
config.put(MediaConstants.TrackerConfig.CHANNEL, "custom-channel");  // Overwrites channel configured in the Data Collection UI.
config.put(MediaConstants.TrackerConfig.AD_PING_INTERVAL, 1);  // Overwrites ad content ping interval to 1 second.
config.put(MediaConstants.TrackerConfig.MAIN_PING_INTERVAL, 30);  // Overwrites main content ping interval to 30 seconds.

MediaTracker mediaTracker = Media.createTracker(config);  // Use the instance for tracking media.
Kotlin
val config = mapOf(
                MediaConstants.TrackerConfig.CHANNEL to "custom-channel",
                MediaConstants.TrackerConfig.AD_PING_INTERVAL to 1,
                MediaConstants.TrackerConfig.MAIN_PING_INTERVAL to 30,
            )

val mediaTracker = Media.createTracker(config) // Use the instance for tracking media.

createMediaObject

Creates an instance of the Media object.

Parameter Description Required
name The name of the media Yes
id The unqiue identifier for the media Yes
length The length of the media in seconds Yes
streamType Stream type Yes
mediaType Media type Yes

Syntax

public static HashMap<String, Object> createMediaObject(String name,
                                                        String id,
                                                        int length,
                                                        String streamType,
                                                        MediaType mediaType);

Example

Java
HashMap<String, Object> mediaInfo = Media.createMediaObject("video-name",
                                                            "video-id",
                                                            60,
                                                            MediaConstants.StreamType.VOD,
                                                            Media.MediaType.Video);
Kotlin
var mediaInfo = Media.createMediaObject("video-name",
                                        "video-id",
                                        60,
                                        MediaConstants.StreamType.VOD,
                                        Media.MediaType.Video)

createAdBreakObject

Creates an instance of the AdBreak object.

Parameter Description Required
name The friendly name of the Ad break such as pre-roll, mid-roll, or post-roll Yes
position The numeric position of the Ad break within the content, starting with 1 Yes
startTime The playhead value in seconds at the start of the ad break Yes

Syntax

public static HashMap<String, Object> createAdBreakObject(String name, int position, int startTime);

Example

Java
HashMap<String, Object> adBreakObject = Media.createAdBreakObject("adbreak-name", 1, 0);
Kotlin
val adBreakObject = Media.createAdBreakObject("adbreak-name", 1, 0)

createAdObject

Creates an instance of the Ad object.

Parameter Description Required
name The friendly name of the Ad Yes
id The unique identifier for the Ad Yes
position The numeric position of the Ad within the ad break, starting with 1 Yes
length The length of Ad in seconds Yes

Syntax

public static HashMap<String, Object> createAdObject(String name, String id, int position, int length);

Example

Java
HashMap<String, Object> adInfo = Media.createAdObject("ad-name", "ad-id", 1, 15);
Kotlin
val adInfo = Media.createAdObject("ad-name", "ad-id", 1, 15)

createChapterObject

Creates an instance of the Chapter object.

Parameter Description Required
name The friendly name of the Chapter Yes
position The numeric position of the Chapter within the content, starting with 1 Yes
length The length of Chapter in seconds Yes
startTime The playhead value at the start of the chapter Yes

Syntax

public static HashMap<String, Object> createChapterObject(String name,
                                                          int position,
                                                          int length,
                                                          int startTime);

Example

Java
HashMap<String, Object> chapterInfo = Media.createChapterObject("chapter-name", 1, 60, 0);
Kotlin
val chapterInfo = Media.createChapterObject("chapter-name", 1, 60, 0)

createQoEObject

Creates an instance of the QoE object.

Parameter 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

Syntax

public static HashMap<String, Object> createQoEObject(int bitrate,
                                                      int startupTime,
                                                      int fps,
                                                      int droppedFrames);

Example

Java
HashMap<String, Object> qoeInfo = Media.createQoEObject(10000000, 2, 23, 10);
Kotlin
val qoeInfo = Media.createQoEObject(10000000, 2, 23, 10)

createStateObject

Creates an instance of the Player State object.

Parameter Description Required
name The player state name. Use Player State constants to track standard player states Yes

Syntax

public static HashMap<String, Object> createStateObject(String stateName);

Example

Java
HashMap<String, Object> playerStateInfo = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);
Kotlin
val playerStateInfo = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)

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.

Parameter 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

Syntax

public void trackSessionStart(Map<String, Object> mediaInfo, Map<String, String> contextData);

Example

Java
HashMap<String, Object> mediaObject = Media.createMediaObject("media-name", "media-id", 60, 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 keys
mediaMetadata.put("isUserLoggedIn", "false");
mediaMetadata.put("tvStation", "Sample TV Station");

tracker.trackSessionStart(mediaInfo, mediaMetadata);
Kotlin
val mediaObject = Media.createMediaObject(
                        "media-name",
                        "media-id",
                        60,
                        MediaConstants.StreamType.VOD,
                        Media.MediaType.Video
                    )

val mediaMetadata = mutableMapOf<String, String>()
// Standard metadata keys provided by adobe.
mediaMetadata[MediaConstants.VideoMetadataKeys.EPISODE] = "Sample Episode" 
mediaMetadata[MediaConstants.VideoMetadataKeys.SHOW] = "Sample Show"
// Custom metadata keys
mediaMetadata["isUserLoggedIn"] = "false"
mediaMetadata["tvStation"] = "Sample TV Station"

tracker.trackSessionStart(mediaInfo, mediaMetadata)

trackPlay

Tracks the media play, or resume, after a previous pause.

Syntax

public void trackPlay();

Example

Java
tracker.trackPlay();
Kotlin
tracker.trackPlay()

trackPause

Tracks the media pause.

Syntax

public void trackPause();

Example

Java
tracker.trackPause();
Kotlin
tracker.trackPause()

trackComplete

Tracks media complete. Call this method only when the media has been completely viewed.

Syntax

public void trackComplete();

Example

Java
tracker.trackComplete();
Kotlin
tracker.trackComplete()

trackSessionEnd

Tracks the end of a viewing session. Call this method even if the user does not view the media to completion.

Syntax

public void trackSessionEnd();

Example

Java
tracker.trackSessionEnd();
Kotlin
tracker.trackSessionEnd()

trackError

Tracks an error in media playback.

Parameter Description Required
errorId Error Information Yes

Syntax

public void trackError(String errorId);

Example

Java
tracker.trackError("errorId");
Kotlin
tracker.trackError("errorId")

trackEvent

Tracks media events.

Parameter Description Required
event The media event being tracked, use Media event constants Yes
info For an AdBreakStart event, the adBreak information is created by using the createAdBreakObject method.
For an AdStart event, the Ad information is created by using the createAdObject method.
For ChapterStart event, the Chapter information is created by using the createChapterObject method.
For StateStart and StateEnd event, the State information is created by using the createStateObject method.
Yes/No*
data Optional context data can be provided for AdStart and ChapterStart events. This is not required for other events. No

Note
* info is a required parameter for AdBreakStart, AdStart, ChapterStart, StateStart, StateEnd events. Not set for any other event types.

Syntax

public void trackEvent(Media.Event event, Map<String, Object> info, Map<String, String> data);

Example

Tracking player States

Java
// StateStart
  HashMap<String, Object> stateObject = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);
  tracker.trackEvent(Media.Event.StateStart, stateObject, null);

// StateEnd
  HashMap<String, Object> stateObject = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN);
  tracker.trackEvent(Media.Event.StateEnd, stateObject, null);
Kotlin
// StateStart
    val stateObject = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)
    tracker.trackEvent(Media.Event.StateStart, stateObject, null)

// StateEnd
    val stateObject = Media.createStateObject(MediaConstants.PlayerState.FULLSCREEN)
    tracker.trackEvent(Media.Event.StateEnd, stateObject, null)

Tracking ad breaks

Java
// AdBreakStart
  HashMap<String, Object> adBreakObject = Media.createAdBreakObject("adbreak-name", 1, 0);
  tracker.trackEvent(Media.Event.AdBreakStart, adBreakObject, null);

// AdBreakComplete
  tracker.trackEvent(Media.Event.AdBreakComplete, null, null);
Kotlin
// AdBreakStart
    val adBreakObject = Media.createAdBreakObject("adbreak-name", 1, 0)
    tracker.trackEvent(Media.Event.AdBreakStart, adBreakObject, null)

// AdBreakComplete
    tracker.trackEvent(Media.Event.AdBreakComplete, null, null)

Tracking ads

Java
// AdStart
  HashMap<String, Object> adObject = Media.createAdObject("ad-name", "ad-id", 1, 15);

  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 keys
  adMetadata.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);
Kotlin
//AdStart
    val adObject = Media.createAdObject("ad-name", "ad-id", 1, 15)

    val adMetadata = mutableMapOf<String, String>()
    // Standard metadata keys provided by adobe.
    adMetadata[MediaConstants.AdMetadataKeys.ADVERTISER] = "Sample Advertiser"
    adMetadata[MediaConstants.AdMetadataKeys.CAMPAIGN_ID] = "Sample Campaign"
    // Custom metadata keys
    adMetadata["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

Java
// ChapterStart
  HashMap<String, Object> chapterObject = Media.createChapterObject("chapter-name", 1, 60, 0);

  HashMap<String, String> chapterMetadata = new HashMap<String, String>();
  chapterMetadata.put("segmentType", "Sample segment type");

  tracker.trackEvent(Media.Event.ChapterStart, chapterObject, chapterMetadata);

// ChapterComplete
  tracker.trackEvent(Media.Event.ChapterComplete, null, null);

// ChapterSkip
  tracker.trackEvent(Media.Event.ChapterSkip, null, null);
Kotlin
// ChapterStart
  val chapterObject = Media.createChapterObject("chapter-name", 1, 60, 0)

  val chapterMetadata = HashMap<String, String>()
  chapterMetadata["segmentType"] = "Sample segment type"

  tracker.trackEvent(Media.Event.ChapterStart, chapterObject, chapterMetadata)

// ChapterComplete
  tracker.trackEvent(Media.Event.ChapterComplete, null, null)

// ChapterSkip
  tracker.trackEvent(Media.Event.ChapterSkip, null, null)

Tracking playback events

Java
// 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);
Kotlin
// 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

Java
// If the new bitrate value is available provide it to the tracker.
  HashMap<String, Object> qoeObject = Media.createQoEObject(2000000, 2, 25, 10);
  tracker.updateQoEObject(qoeObject);

// Bitrate change
  tracker.trackEvent(Media.Event.BitrateChange, null, null);
Kotlin
// If the new bitrate value is available provide it to the tracker.
  val qoeObject = Media.createQoEObject(2000000, 2, 25, 10)
  tracker.updateQoEObject(qoeObject)

// Bitrate change
  tracker.trackEvent(Media.Event.BitrateChange, null, null)

updateCurrentPlayhead

Provides the current media playhead to the media tracker instance. For accurate tracking, call this method everytime the playhead changes. If the player does not notify playhead changes, call this method once every second with the most recent playhead.

Parameter Description
time Current playhead in seconds.

For video-on-demand (VOD), the value is specified in seconds from the beginning of the media item.

For live streaming, if the player does not provide information about the content duration, the value can be specified as the number of seconds since midnight UTC of that day.
Note: When using progress markers, the content duration is required and the playhead needs to be updated as number of seconds from the beginning of the media item, starting with 0.

Syntax

public void updateCurrentPlayhead(int time);

Example

Java
tracker.updateCurrentPlayhead(1);
Kotlin
tracker.updateCurrentPlayhead(1)
}

Live streaming example

Java
//Calculation for number of seconds since midnight UTC of the day
int timeFromMidnightInSecond = (int)((System.currentTimeMillis() / 1000) % 86400);
tracker.updateCurrentPlayhead(timeFromMidnightInSecond);
Kotlin
//Calculation for number of seconds since midnight UTC of the day
val timeFromMidnightInSecond = (System.currentTimeMillis() / 1000 % 86400).toInt()
tracker.updateCurrentPlayhead(timeFromMidnightInSecond);

updateQoEObject

Provides the media tracker with the current QoE information. For accurate tracking, call this method multiple times when the media player provides the updated QoE information.

Parameter Description
qoeInfo Current QoE information that was created by using the createQoEObject method.

Syntax

public void updateQoEObject(Map<String, Object> qoeInfo);

Example

Java
HashMap<String, Object> qoeObject = Media.createQoEObject(1000000, 2, 25, 10);
tracker.updateQoEObject(qoeObject);
Kotlin
val qoeObject = Media.createQoEObject(1000000, 2, 25, 10)
tracker.updateQoEObject(qoeObject)

Media Constants

Refer MediaConstants.java to see the constants exposed by Media extension.