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

Build Configurations

1. Get the Streamhub Analytics plugin for tvOS

Either get it from the Downloads page or request from your account manager.

2. Copy the plugin files

The download contains a tvOS sample app for Brightcove that make usage of the plugin files.

There is no binary files provided. You just copy the files StreamhubBrightcove.m, NetworkUI.m along with their respective header files from the sample app and add them to your own video player project.

3. Add dependency configurations

The plugin depends on the AFNetworking library to make the HTTP requests and on the Brightcove SDK for tvOS that you can download from there: https://github.com/brightcove/brightcove-player-sdk-ios/releases/tag/v5.0.1

For tvOS, it is required to use the version 3.0 of the AFNetworking library or earlier.

If you use cocoapod to manage your dependancies, this is how your cocoa Podfile should look like:

platform :tvos
pod 'AFNetworking', '~> 3.0'

then open a terminal and type
$ cd 'project folder' && pod install

to install the required dependancies

4. Get your Streamhub analyticsId and playerId

Your analyticsId will be or has already been provided to you by your Streamhub account manager.

You can generate a playerId (unique String identifier) for your specific video player and communicate it to us, or you can ask us to generate it for you.

In either cases, the playerId has to be  registered  in both our and your system.

Code sample

In order to actually use the plugin, there is 2 simple steps:

[code language=”objc”]
_avpvc = [[AVPlayerViewController alloc] init];

BCOVPlayerSDKManager *manager = [BCOVPlayerSDKManager sharedManager];

// 1) Create the plugin with your analyticsId
StreamhubBrightcove* plugin = [[StreamhubBrightcove alloc] initPlugin:@"1.0" analytiscId:@"streamhub-b106d" playerId:@"891BB11F-55C8-4797-B987-E348EEC399D3"];

_playbackController = [manager createPlaybackControllerWithViewStrategy:[manager defaultControlsViewStrategy]];
_playbackController.delegate = self;
_playbackController.autoAdvance = YES;
_playbackController.autoPlay = YES;

// 2) Use the plugin by attaching it to the playbackController
[_playbackController addSessionConsumer:plugin];
[/code]

Test

To confirm the plugin is integrated properly into your application, you should see the following logs in the Xcode console:

2015-MM-dd HH:mm:sss NativeControls[172:3688] Player API:

The app should send 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
  • you click on start, pause and play the video
  • the app will send completion events if the video duration is known.

Appendix

Streamhub Data Flow

Streamhub Data Flow

Figure: Streamhub Data Flow with external sources