Datazoom is a high-availability real-time data collection solution. This document summarizes how to integrate the Akamai Adaptive Media Player for Android with the Datazoom platform.
-
Login to Datazoom here: https://app.datazoom.io
-
Add a Collector as indicated here: How to add a Collector
-
Copy the
config key
that was created at the end of the process
Click the icon indicated below to copy the Configuration Key
4. Replace the <configuration id from Datazoom>
in your AkamaiPlayerCollector
project with the Key you copied above.
5. Replace the <url given by Datazoom>
with <https://platform.datazoom.io/beacon/v2/>
Adding dependencies to your project
This library uses the amp-core library from Akamai Premier releases:
AMP for Devices - Premier: Android Build 9.9.6 (https://mdtp-a.akamaihd.net/amp-android-sdk/premier )
-
Add the following maven repository URL in your project's build.gradle file
// Snapshot Repository maven { url 'https://gitlab.com/api/v4/projects/18323233/packages/maven' } // Release Repository maven { url 'https://gitlab.com/api/v4/projects/10353305/packages/maven' }
-
Add the following dependency in your project's build.gradle file's dependencies block
Lib - AkamaiGoldCollector
dependencies { implementation 'com.datazoom.android:base-collector-gold:3.6.3' implementation 'com.datazoom.android:akamai-gold-collector:2.3.1' }
-
Add following compile options if you don't have it already
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
-
Append the following rules to the
proguard-rules
files, if you are using them in your app-keep class com.dz.collector.android.model.SuccessfulServerResponse** -keepclassmembers class com.dz.collector.android.model.SuccessfulServerResponse* {;}
-
Add AMP Core library to your project
The Datazoom collector library uses the amp-core library for data collection.
We've excluded the amp-core library from the collector library for customer convenience.
The version and link to download the core library is: AMP for Devices - Premier: Android Build 9.9.6 (https://mdtp-a.akamaihd.net/amp-android-sdk/premier) -
Add the following additional dependencies to your project
dependencies { implementation 'com.google.guava:guava:27.1-android' }
-
Use the following code snippet to add AkamaiPlayerCollector to your project.
The following code snippet illustrates the usage of the AkamaiPlayer collector. Open demo application's
MainActivity.java
to see a running example.String configId = "<configuration id from Datazoom>"; String configUrl = "<url given by Datazoom>"; AkamaiPlayerCollector akamaiPlayerCollector = AkamaiPlayerCollector.create(videoPlayerView, MainActivity.this); akamaiPlayerCollector.setConfig(new DatazoomConfig(configId, configUrl)) .connect(new DZBeaconConnector.ConnectionListener() { public void onSuccess(DZEventCollector dzEventCollector) { //Everything is setup, collector initialization complete. } public void onError(Throwable t) { //Error while creating akamai player collector //showAlert("Error", "Error while creating AkamaiPlayerCollector, error:" + t.getMessage()); } });
-
After the player is done playing a content, invoke the collector’s
releasePlayer()
method to stop data collection for the player. Later if the same or a different play instance is used to play contents again, invoke the collector’ssetPlayer()
method to start data collection.// when content playing is done (completed or aborted) akamaiPlayerCollector.releasePlayer(); ... // before requesting content playback again akamaiPlayerCollector.setPlayer(videoPlayerView);
CUSTOM EVENTS & METADATA
Datazoom allows customers to collect custom events and metadata that don't originate from a video player.
Custom Metadata
-
Create a JSONArray with necessary metadata
JSONArray metadata = new JSONArray( "[{\"customMetadata\": \"MetadataValue\"}]");
-
Add the metadata to DZEventCollector
DZEventCollector.setCustomMetadata(metadata);
Example:
String configId = "<configuration id from Datazoom>"; String configUrl = "<url given by Datazoom>"; //Setup CustomMetadata here try { DZEventCollector.setCustomMetadata(new JSONArray("[{\"customPlayerName\": \"Akamai Player\"},{\"customDomain\": \"devplatform.io\"}] ")); } catch (JSONException e) { e.printStackTrace(); } AkamaiPlayerCollector.create(videoPlayerView, MainActivity.this) .setConfig(new DatazoomConfig(configId, configUrl)) .connect(new DZBeaconConnector.ConnectionListener() { public void onSuccess(DZEventCollector dzEventCollector) { } public void onError(Throwable t) { } });
Custom Events
-
Create an Event object
Event event = new Event("Custom_Event_Name", new JSONArray());
The first constructor parameter is the event name, and the second is a list of custom metadata to be included in the event. -
Add the event to DZEventCollector
dzEventCollector.addCustomEvent(event);
Example:
@Override public void onSuccess(DZEventCollector dzEventCollector) { Event event = new Event("SDKLoaded", new JSONArray()); dzEventCollector.addCustomEvent(event); btnPush.setOnClickListener(v - > { try { Event event1 = new Event("buttonClick", new JSONArray("[{\"customakamaiPlay\": \"true\"}, {\"customakamaiPause\": \"true\"}] ")); dzEventCollector.addCustomEvent(event1); } catch (JSONException e) { e.printStackTrace(); } }); }
-
Google IMA Ad Integration
-
Add the following dependencies in your project's build.gradle file's dependencies block.
dependencies { implementation 'com.datazoom.android:plugin-google-ima:4.39.0' api 'com.google.ads.interactivemedia.v3:interactivemedia:3.10.7' }
-
Setup Google IMA Ad listener.
After the collector initialization call this method.private void setupAdListeners(final DZEventCollector dzEventCollector) { if (adsManager != null) { adsManager.addAdEventListener((AdEvent.AdEventListener) dzEventCollector.adListener()); } }
Sample code :- https://gitlab.com/datazoom/mobile-android-group/mobile-android-akamai-demo/-/tree/Plugin-Google-IMA
Customers Using Freewheel Ads
Add the freewheel manager libraries from Akamai Premier releases to your project.
-
Setup the Freewheel Manager listener.
After the collector initialization call this method@Override public void onSuccess(DZEventCollector dzEventCollector) { if (freewheelManager != null) { freewheelManager.addEventsListener((IAdsComponentListener) dzEventCollector); } }
Comments
0 comments
Article is closed for comments.