Skip to content

Instantly share code, notes, and snippets.

@paulofaria
Last active December 6, 2016 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulofaria/140b4acb9b3d0affd9c6a45ab9d610a6 to your computer and use it in GitHub Desktop.
Save paulofaria/140b4acb9b3d0affd9c6a45ab9d610a6 to your computer and use it in GitHub Desktop.

Plugin integration

Integrating the plugin with AVPlayer is done by linking SenseKit framework to your player. Here we describe how to integrate your player with SenseKit.

Pre-Requisites

  • A valid Sense CID

Installing SenseKit

Download SenseKit

First we need to download SenseKit:

https://agent.nexeven.io/current/ios-avplayer/avplayer-sense-agent.framework.zip

Unzip SenseKit

After you download SenseKit extract it somewhere. It will look like this:

SenseKit

Move SenseKit.framework to your project's directory

Move the SenseKit.framework file equivalent to your platform (iOS, Mac, tvOS) to your application's directory. In our example we moved it to the Frameworks directory next to our Xcode project, but you can move it anywhere you want.

SenseKit

Drag and Drop SenseKit.framework into your Xcode project

Now you just need to drag and drop SenseKit.framework into the Embedded Binaries section in your target configuration.

SenseKit

Configuring the plugin

Now just import the framework and configure the plugin using your instance of AVPlayer and your info.

Objective-C

@import SenseKit;

...

NECustomMetadata *assetMetadata = [NECustomMetadata alloc];
assetMetadata.key = @"AMK1";
assetMetadata.values = @[@"AMV1", @"AMV11"];

NECustomMetadata *viewerMetadata = [NECustomMetadata alloc];
viewerMetadata.key = @"CMK1";
viewerMetadata.values = @[@"CMV1", @"CMV11"];

NESenseAgent *agent = [[NESenseAgent alloc] initWithAVPlayer:player // your AVPlayer instance
                                                     assetId:assetId
                                                  serverHost:@"https://sense.nexeven.io"
                                                      nxeCID:@"BBQCID"
                                                   assetType:assetType
                                                   assetName:assetName
                                                    viewerId:@"jorgenS"
                                               assetMetadata:@[assetMetadata]
                                              viewerMetadata:@[viewerMetadata]];

Swift

import SenseKit

...

let assetMetadata = CustomMetadata()
assetMetadata.key = "AMK1"
assetMetadata.values = ["AMV1", "AMV11"]

let viewerMetadata = CustomMetadata()
viewerMetadata.key = "CMK1"
viewerMetadata.values = ["CMV1", "CMV11"]

let agent = SenseAgent(
    player: player, // your AVPlayer instance
    assetId: assetId,
    nxeCID: "BBQCID",
    assetType: assetType,
    assetName: assetName,
    viewerId: "jorgenS",
    assetMetadata: [assetMetadata],
    viewerMetadata: [viewerMetadata]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment