Conviva.Client
|
ConvivaAnalytics
|
Client _client = new Client(_clientSettings, _androidSystemFactory);
|
ConvivaAnalytics.init(getApplicationContext(), PRODUCTION_CUSTOMER_KEY);
// ConvivaAnalytics is a global object, not a return object like 'client'.
// Note that the most important parameter (CUSTOMER_KEY) now becomes separate argument,
// not part of 'ClientSettings'
|
SystemInterface _androidSystemInterface =
AndroidSystemInterfaceFactory.buildSecure(context);
|
Not needed. |
SystemSettings _systemSettings = new SystemSettings();
_systemSettings.logLevel = SystemSettings.LogLevel.DEBUG;
_systemSettings.allowUncaughtExceptions = false;
|
Not needed. |
SystemFactory _androidSystemFactory =
new SystemFactory(_androidSystemInterface, _systemSettings);
|
Not needed. |
ClientSettings_clientSettings = new ClientSettings(customerKey);
_clientSettings.gatewayUrl = gatewayUrl;
|
The settings are defined as an HashMap
which can take values of pre-defined constants
as keys:
Map<String, Object> settings = new HashMap<String, Object>();
String gatewayUrl = "Touchstone Service URL";
settings.put(ConvivaSdkConstants.GATEWAY_URL, gatewayUrl);
settings.put(ConvivaSdkConstants.LOG_LEVEL, ConvivaSdkConstants.LogLevel.DEBUG);
ConvivaAnalytics.init(getApplicationContext(), TEST_CUSTOMER_KEY, settings);
|
PlayerStateManager
|
ConvivaVideoAnalytics for main video content and ConvivaAdAnalytics for advertisement content. |
client.getPlayerStateManager()
|
var convivaVideoAnalytics = ConvivaAnalytics.buildVideoAnalytics();
var convivaAdAnalytics = ConvivaAnalytics.buildAdAnalytics();
|
playerStateManager.setClientMeasureInterface(mXYZPlayerInterface);
Implement IClientMeasureInterface & override getPHT()
Implement IClientMeasureInterface & override getBufferLength()
playerStateManager.setRenderedFrameRate(renderedFramerate);
|
Implement a callback function and pass the callback function to the videoAnalytics.setCallback() method. In the callback function, report values for the individual metrics using generic videoAnalytics.reportPlaybackMetric() API.
Example:
ConvivaExperienceAnalytics.ICallback callback =
new ConvivaExperienceAnalytics.ICallback() {
@Override public void update() {
videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH,
length);
videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME,
pht);
videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE,
frameRate);
}
};
|
Client.attachPlayer()
|
Not needed for SDK integrations. Report metrics directly to videoAnalytics.
In case of "module" integrations, for example, ExoPlayer, use videoAnalytics.setPlayer(contentPlayer).
|
Client.createSession(contentInfo)
|
videoAnalytics.reportPlaybackRequested(ContentInfo)
|
Client.reportError()
|
There are two alternate methods:
- The method which does 3 actions in one – create session, report error, and cleanup session:
videoAnalytics.reportPlaybackFailed(message, contentInfo=);
- The method which reports an error and creates a session if
reportPlaybackRequested() is not called before:
videoAnalytics.reportPlaybackError(message, severity);
If you have retry logic, then use the second method.
|
playerStateManager.setPlayerState();
playerStateManager.setBitrateKbps();
and other methods that report metrics
|
videoAnalytics.reportPlaybackMetric(metric_key, metric_value)
For player state (ConvivaSdkConstants.PLAYBACK.PLAYER_STATE), use the parameter metric_key.
For bitrate (ConvivaSdkConstants.PLAYBACK.BITRATE) and other metrics, see here.
|
playerStateManager.setVideoWidth(w);
playerStateManager.setVideoHeight(h);
|
videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.RESOLUTION, w, h);
|
playerStateManager.setPlayerSeekStar(pos);
|
videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.SEEK_START, pos);
|
playerStateManager.setPlayerSeekEnd();
|
videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.SEEK_END);
|
playerStateManager.setBitrateKbps(currentRenderingBitrateKbps);
|
//Value should be integer
videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.BITRATE, bitrate);
|
| Clean up the session when the application is backgrounded. |
ConvivaAnalytics.reportAppBackgrounded();
|
| Re-create a new session when the application is foregrounded.
|
ConvivaAnalytics.reportAppForegrounded();
|
Client.updateContentMetadata(contentSessionKey, contentMetadata);
|
videoAnalytics.setContentInfo(contentInfo);
|
|
On events such as bumper video or pop up requiring user wait,
the solution was to call Client.adStart() or Client.adEnd().
|
We introduced dedicated API calls for these use cases.
//To report start user dialog pop up displayed:
videoAnalytics.reportPlaybackEvent(ConvivaSdkConstants.USER_WAIT_STARTED);
//To report dismiss of user dialog pop up
videoAnalytics.reportPlaybackEvent(ConvivaSdkConstants.USER_WAIT_ENDED);
// To report bumper video start
videoAnalytics.reportPlaybackEvent(ConvivaSdkConstants.BUMPER_VIDEO_STARTED);
// To report completion of bumper video:
videoAnalytics.reportPlaybackEvent(ConvivaSdkConstants.BUMPER_VIDEO_ENDED);
|
Client.cleanupSession(contentSessionKey);
|
videoAnalytics.reportPlaybackEnded();
|
mPlayerInterface.cleanup();
Client.releasePlayerStateManager(playerStateManager);
Client.release();
|
videoAnalytics.release();
ConvivaAnalytics.release();
|
//SET framework name
playerStateManager.setPlayerType("FRAMEWORK_NAME");
//SET PLAYER FRAMEWORK VERSION
playerStateManager.setPlayerVersion("1.2.3.4");
|
Map<String, Object> playerInfo = new HashMap<String, Object>();
playerInfo.put(ConvivaSdkConstants.FRAMEWORK_NAME,"FRAMEWORK_NAME");
// SET PLAYER FRAMEWORK VERSION
playerInfo.put(ConvivaSdkConstants.FRAMEWORK_VERSION, "1.2.3.4");
videoAnalytics.setPlayerInfo(playerInfo);
|
|
Handle Ads:
Client.adStart(contentSessionKey, Client.AdStream.SEPARATE,
Client.AdPlayer.SEPARATE, Client.AdPosition.PREROLL);
Client.adEnd(contentSessionKey);
|
// On ad break start
ConvivaAnalytics.reportAdBreakStarted(/* ConvivaSdkConstants.AdType */ adType,
/* ConvivaSdkConstants.AdPlayer */ adPlayer);
// on ad break end
ConvivaAnalytics.reportAdBreakEnded();
|
|
"Pod" Events:
attributes.put("podDuration", "60");
attributes.put("podPosition", "Preroll");
attributes.put("podIndex", "1");
attributes.put("absoluteIndex", "1");
String eventName = "Conviva.PodStart";
Client.sendCustomEvent(contentSessionKey, eventName, attributes);
|
No need to explicitly send Pod Events.
It is covered by
the reportAdBreakStarted() and reportAdBreakEnded() API calls.
|
Map <string, object=""> attributes = new HashMap <(String, Object)>();
attributes.put("location" : "Toolbar");
attributes.put("assetName" : "Sample Video");
attributes.put("shareService" : "Facebook");
String eventName = "share-click";
Client.sendCustomEvent(Client.NO_SESSION_KEY,eventName, attributes)
|
// New code uses ConvivaAnalytics to send the event
String eventType = "share-click";
Map<String, Object> attr = new HashMap<> ();
attr.put("location", "Toolbar");
attr.put("assetName", "Sample Video");
attr.put("shareService", "Facebook");
ConvivaAnalytics.reportAppEvent(eventType, attr);
|