@adobe/vega-aepmedia
v1.0.1
Published
Adobe Experience Platform Media Analytics SDK.
Downloads
51
Readme
Adobe Experience Platform Vega SDK — Media API Reference
This document describes the public APIs provided by @adobe/vega-aepmedia (Adobe Experience Platform Media Analytics) for Amazon Vega (Kepler) React Native apps. The Media package depends on @adobe/vega-aepcore and registers a Media extension that works with the core SDK’s event hub and Edge pipeline.
IMPORTANT
- Initialize @adobe/vega-aepcore with
Media.EXTENSIONbefore using media APIs.- A media session must be started with
createMediaSessionbeforesendMediaEvent.
Contents
Installation
Add the core and media packages to your app (versions should stay aligned per your release):
yarn add @adobe/vega-aepcore @adobe/vega-aepmediaRegister the Media extension
Pass Media.EXTENSION in the extensions array when calling AEPSDK.initialize from @adobe/vega-aepcore.
Example
import { AEPSDK, LogLevel } from '@adobe/vega-aepcore';
import { Media } from '@adobe/vega-aepmedia';
await AEPSDK.initialize({
config: {
'edge.configId': '<YOUR_DATASTREAM_ID>',
},
logLevel: LogLevel.VERBOSE,
extensions: [Media.EXTENSION],
});Media APIs
Media.EXTENSION
The Extension instance used to register the Media component with the core SDK. Pass it only to AEPSDK.initialize({ extensions: [...] }).
Syntax
readonly EXTENSION: Extension;createMediaSession
Creates a new media session using XDM data whose event type is media.sessionStart. Invalid or incomplete XDM may be rejected internally (check SDK logs).
The implementation validates XDM via MediaAPIHelper, assigns a default playerId, and dispatches a createMediaSession event on the core event hub.
Syntax
createMediaSession(data: Record<string, unknown>): void;Parameters
data: Object containing XDM formedia.sessionStart, typically includingmediaCollectionwithsessionDetails. Session start flows are described in Adobe’s Media Edge documentation (see Further reading).
NOTE
sessionDetailsmust satisfy the session details field group requirements for your implementation.
Example
import { Media } from '@adobe/vega-aepmedia';
const sessionStartXDM = {
xdm: {
eventType: 'media.sessionStart',
mediaCollection: {
playhead: 0,
sessionDetails: {
streamType: 'video',
friendlyName: 'Name of the media',
hasResume: false,
name: 'CONTENT_ID',
length: 100,
contentType: 'vod',
channel: 'SampleChannel',
playerName: 'SamplePlayer',
},
},
},
};
Media.createMediaSession(sessionStartXDM);sendMediaEvent
Sends a media lifecycle or analytics event (play, pause, ping, ad events, session end, etc.) for the active session. createMediaSession must have been called successfully first.
Syntax
sendMediaEvent(data: Record<string, unknown>): void;Parameters
data: XDM payload for the event (e.g.eventType:media.play,media.ping,media.sessionEnd, …) withmediaCollectionincludingplayheadwhere required by the event type.
Example — media.play
import { Media } from '@adobe/vega-aepmedia';
const playhead = 0; // integer, non-negative
const playXDM = {
xdm: {
eventType: 'media.play',
mediaCollection: {
playhead,
},
},
};
Media.sendMediaEvent(playXDM);Example — media.ping
const pingXDM = {
xdm: {
eventType: 'media.ping',
mediaCollection: {
playhead: currentPlayhead,
},
},
};
Media.sendMediaEvent(pingXDM);Session and playback notes
- Active session: Use
sendMediaEventonly after a session has been started withcreateMediaSession. - Single session: Only one media session should be active at a time. To start another session, end the current one with the appropriate session-complete / session-end events per Media Edge API guidance.
- Pings: During playback, send
media.pingat the required cadence with an up-to-dateplayheadso the server can track progress reliably. - Playhead: Use a non-negative integer for
playheadwhere applicable; invalid values may be treated as errors.
