Streamhub Analytics plugin for Brightcove SDK for Android

To start tracking your videos from your Android OS based apps with
Streamhub, please follow these implementation instructions.

Build Configurations

1. Get the Streamhub Analytics plugin

Download and extract the archive from http://streamhub-static-content.s3.amazonaws.com/plugins/brightcove/brightcove-android.zip

2. Place the plugin project

Currently, since the plugin is not provided as a binary file, you just need to drop the plugin implementation files somewhere under your project structure.

3. Edit build configuration file

To compile the plugin into your app you need to add
StreamhubBrightcovePlugin into your build.gradle:

dependencies {

...
compile project(':StreamhubBrightcovePlugin')

}

4. Get your Streamhub analyticsId

Your analyticsId will be or has already been provided by Streamhub to you. Use this ID in the implementation steps described next.

Implementation

What you need to do is very simple as following 2 steps:

1. Add import for the plugin

import uk.co.streamhub.brightcoveplugin.StreamhubAnalytics;

2. Initialise the plugin

public class MainActivity extends Activity {
    private final String TAG = this.getClass().getSimpleName();

    BrightcoveVideoView bcVideoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        bcVideoView = 
                (BrightcoveVideoView) findViewById(R.id.bc_video_view);

        Catalog catalog = new Catalog("<Brightcove Catalogue ID>");
        catalog.findVideoByID("<Video ID>", new VideoListener() {
            public void onVideo(Video video) {
                bcVideoView.add(video);
                bcVideoView.start();
            }
        });

        /* ADD THIS INITIALISATION CODE */
        // Initialise StreamhubAnalytics plugin for Brightcove
        // Arg1: Context
        // Arg2: BrightcoveVideoView
        // Arg3: playerId - Must be unique in your system and communicated to us
        // e.g. Use a UUID version 4
        // Arg4: analyticsId - this ID is provide by Streamhub
        new StreamhubAnalytics(this, bcVideoView, 
                                     "<playerId>",
                                     "<analyticsId>");
    }
}

Confirm the plugin is integrated

Here is the ways to confirm the plugin is integrated properly into your app.

  1. You may see “StreamhubAnalytics” tag in logcat, if StreamhubAnalytics plugin is built into your app properly.
  2. The app requests to stats.streamhub.io in the following cases:
    • every 5 seconds in the first 60 seconds position of the video
    • every 1 minute (after the first 60 seconds) afterwards

Appendix

Streamhub Data Flow

Streamhub Data Flow

Figure: Streamhub Data Flow with external sources