Streamhub Analytics plugin for Brightcove SDK for iOS
To start tracking your videos from your iOS 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-ios.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 in your project directory / add them to your Xcode project.
3. Add dependency configurations
Since the plugin depends on a couple of libraries, you need to add them into your Podfile.
- Brightcove Player SDK for iOS
- Basically, you already have it in your Podfile
- AFNetworking
A sample Podfile looks like this:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! target 'BrightcovePluginForIOS' do pod 'Brightcove-Player-SDK', '~> 5.2' pod "AFNetworking", "~> 2.0" end then open a terminal and type $ cd 'project folder' && pod install to install the required dependancies
4. Get your Streamhub analyticsId
Your analyticsId will be or has already been provided to you by Streamhub. Use this identifier
in the implementation steps described below.
Implementation
In order to actually use the plugin, there is 2 simple steps:
1. Add import for the plugin
#import "StreamhubBrightcove.h"
2. Initialise the plugin
- (void)setup { _avpvc = [[AVPlayerViewController alloc] init]; BCOVPlayerSDKManager *manager = [BCOVPlayerSDKManager sharedManager]; /* Create a plugin instance * initPlugin: * arg-1: playerId : Must be unique in your system. E.g. use a UUID version 4 for instance * arg-2: analyticsId: your personal analyticsId */ StreamhubBrightcove* plugin = [[StreamhubBrightcove alloc] initPlugin:@"my-playerId" analytiscId:@"streamhubX"]; _playbackController = [manager createPlaybackControllerWithViewStrategy: [manager defaultControlsViewStrategy]]; _playbackController.delegate = self; _playbackController.autoAdvance = YES; _playbackController.autoPlay = YES; // Register the plugin as a session consumer [_playbackController addSessionConsumer:plugin]; _catalogService = [[BCOVCatalogService alloc] initWithToken:kViewControllerCatalogToken]; }
the 2 lines in italic case above is all what you need to do in order to use the plugin.
Confirm the plugin is integrated
Here is a simple way to confirm the plugin is integrated properly into your
application.
2015-MM-dd HH:mm:sss NativeControls[172:3688] Player API:
- every 5 seconds in the first 60 seconds position of the video
- every 1 minute (after the first 60 seconds) afterwards