Logo

Application collectors

Bitmovin Media Player

Android Collector

The Bitmovin Media Player is a configuration option for the Android Collector by Datazoom when it is configured with the NaN to make the following additional data points automatically collectable in real time.

  1. (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'
    }

  2. Add following compile options if you don't have it already

    compileOptions

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

  3. 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"
    }

  4. 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());
                        }
                    });
  5. 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.

  1. 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();
         }
    }
  1. 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();
    }
    });
    }