Application collectors
Akamai AMP Media Player
Android Collector
The Akamai AMP Media Player is a configuration option for the Android Collector by Datazoom that makes the following additional data points automatically collectable in real time.
Data Points
Events
Discrete occurrences driven by user interactions or system actions
Metadata
Attributes
Video
User
Fluxdata
Metrics measuring changing parameters over time
Integration instructions
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 Add the following dependency in your project's build.gradle file's dependencies block Lib - AkamaiGoldCollector Add following compile options if you don't have it already Append the following rules to the Add AMP Core library to your project The Datazoom collector library uses the amp-core library for data collection. Add the following additional dependencies to your project 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 After the player is done playing a content, invoke the collector’s 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 Add the metadata to DZEventCollector Example: Custom Events Create an Event object Add the event to DZEventCollector Example: Add the following dependencies in your project's build.gradle file's dependencies block. Setup Google IMA Ad listener. Add the freewheel manager libraries from Akamai Premier releases to your project. Setup the Freewheel Manager listener.// 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'
}
dependencies {
implementation 'com.datazoom.android:base-collector-gold:3.6.4'
implementation 'com.datazoom.android:akamai-gold-collector:2.3.1'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
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* {;}
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)dependencies {
implementation 'com.google.guava:guava:27.1-android'
}
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());
}
});
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’s setPlayer()
method to start data collection.// when content playing is done (completed or aborted)
akamaiPlayerCollector.releasePlayer();
...
// before requesting content playback again
akamaiPlayerCollector.setPlayer(videoPlayerView);
JSONArray metadata = new JSONArray( "[{\"customMetadata\": \"MetadataValue\"}]");
DZEventCollector.setCustomMetadata(metadata);
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) {
}
});
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.dzEventCollector.addCustomEvent(event);
@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
dependencies {
implementation 'com.datazoom.android:plugin-google-ima:4.39.0'
api 'com.google.ads.interactivemedia.v3:interactivemedia:3.10.7'
}
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
After the collector initialization call this method @Override
public void onSuccess(DZEventCollector dzEventCollector) {
if (freewheelManager != null) {
freewheelManager.addEventsListener((IAdsComponentListener) dzEventCollector);
}
}