Datazoom is a high-availability real-time data collection solution. This document summarizes how to integrate the Bitmovin Android video player 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>
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
(a) You can download the latest version of the library file from the below URL and add it into your project's libs directory
android-bitmovin-collector else you can follow step (b)…
(b) Add following maven repository URL in your project's build.gradle file
Maven
maven { // 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 following dependency in your project's build.gradle file's dependencies block
Maven
dependencies { implementation 'com.datazoom.android:base-collector-gold:3.5.0' implementation 'com.datazoom.android:android-bitmovin-collector:3.6.0' }
Add following compile options if you don't have it already
compileOptions
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
Add retrofit library to your project
retrofit
dependencies { implementation 'com.bitmovin.player:player:3.35.0' // Only needed if ads are used implementation "com.google.ads.interactivemedia.v3:interactivemedia:3.29.0" // Only needed if ads are used implementation "com.google.android.gms:play-services-ads-identifier:18.0.1" }
Use the following code snippet to add the BitmovinPlayerCollector to your project.
Following code snippet illustrates the usage of the BitmovinPlayer collector. Open demo application's MainActivity.java to see a running example.String configId = <configuration id from Datazoom>; String configUrl = <url given by Datazoom>; BitmovinPlayerCollector bitmovinPlayerCollector = new BitmovinPlayerCollector(); bitmovinPlayerCollector.create(bitmovinPlayer, BitmovinActivity.this) .setConfig(new DatazoomConfig(configId, configUrl)) .connect(new DZBeaconConnector.ConnectionListener() { @Override public void onSuccess(DZEventCollector dzEventCollector) { sdkInitialized = true; setupCustomMetadata(); setupCustomEvent(dzEventCollector); } @Override public void onError(Throwable t) { showAlert("Error", "Error while creating NativeAndroidConnector, error:" + t.getMessage()); } });
This part of code need to be called inside method onStop() to stop collector
@Override protected void onStop() { super.onStop(); bitmovinPlayerCollector.onStop(); }
Custom Events and Metadata
Datazoom allows customers to collect custom events and metadata that don't originate from a video player.
Custom Metadata
a. Create a JSONArray with necessary metadata
JSONArray metadata = new JSONArray( "[{\"customMetadata\": \"MetadataValue\"}]"); or HashMap<String, Object> metadata = new HashMap<String, Object>;
b. Add the metadata to DZEventCollector
dzEventCollector.setDatazoomMetadata(metadata); or dzEventCollector.setCustomMetadata(HashMap<String, Object> metadata);
Example:
@Override public void onSuccess(DZEventCollector dzEventCollector) { try { dzEventCollector.setDatazoomMetadata(new JSONArray("[{\"customPlayerName\": \"Exo Player\"}," + "{\"customDomain\": " + "\"platform.io\"}]")); } catch (JSONException e) { e.printStackTrace(); } }
Custom Events
a. Create an Event object
Event event = new Event("Custom_Event_Name", new JSONArray()); or Event event = new Event(String type, HashMap<String, Object> metadata);
b. 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("btnPush", new JSONArray("[{\"customPlay\": \"true\"}] ")); dzEventCollector.addCustomEvent(event1); } catch (JSONException e) { e.printStackTrace(); } }); }
Comments
0 comments
Article is closed for comments.