NAV
     

Anvato TvOS SDK

This guide explains how to use the Anvato Player SDK in your TvOS Application.

Features

Anvato TvOS SDK is a collection of video related components that allows your application to have the following functionalities.

Package

The Anvato TvOS SDK is provided as a zipped package. It contains the following files.

Filename Description
libANVSDK.a static library file for Anvato TvOS SDK.
headers folder that contains .h files for the classes defined in the SDK

Along with the SDK package, you will two string values, the AppKey and the SecKey. If you do not have these values, please contact Anvato.

Features

Analytics

Overview

Anvato TvOS SDK provides the following plugins for data tracking and analytics purposes.

Overview

Anvato TvOS SDK provides two types of monitization options using digital ads.

At Anvato, we strongly suggest using server side ad-stitching over client side ads as Ad blockers cannot block server side stitched ads.

Freewheel Settings

Application can set Freewheel settings before ‘load’ video from ‘freewheel’ API on AnvatoConfig instance. Anvato TvOS SDK will use these settings to create the VAST request and get the client side ads that are to be played along with the asset.

getAdTagURL function will return the ad tag url generated using the freewheel parameters when provided with an instance of the ANVMacroManager.

DFP Settings

Application can set DFP settings before using load to play video by using the APIs in the dfp namespace of the AnvatoConfig instance. getAdTagURL function is used to get the ad tag URL. customParams is a dictionary used to set client side dfp parameters of config.

Reliable Streaming

Reliable streaming is built in by default as part of the Anvato TvOS SDK. In case of primary encoder stream failure., the player will switch to the backup encoder and then the backup streams. The backup streams are provided by the Anvato backend and should be configured from there. The Anvato player does this seamlessly and will inform the application using relevant video and data events.

Development Guide

This section describes all the mandatory steps to integrate Anvato TvOS SDK into your application.

  1. Importing the SDK to your workspace
  2. Handling dependencies
  3. Code Integration
  4. Load a sample video

Importing The SDK

To integrate the SDK, please download the latest copy using the developer portal. After unpacking the package, you can simply drag the folder into the XCode's Project Navigation window. A dialog will appear asking you to verify the operation. Check "copy if needed" option select OK. You are done! Now, your application can use the SDK objects simply by including the appropriate header file in the source code.

Dependencies

The application needs to include a list of frameworks libraries. The minimum requirement is listed below.

Frameworks

Libraries

Depending on your application requirements there may be additional libraries that you have to include. The SDK is weak linked to those libraries, meaning that your application will compile even without those libraries however you will not experience the desired behavior if the appropriate third party dependencies are not included.

Project Settings

Implementation

Once all the required binaries are added, the implementation of the SDK can be done in 4 easy steps.

Step 1: Importing Headers

Step 1 Importing Headers

// =================
// ViewController.h
// =================
#import "ANVError.h"
#import "ANVGlobals.h"
#import "ANVSDK.h"
#import "ANVConfig.h"

You can start the integration by importing header files in your source code. You will need at least three header files initially and depending on your application requirements, it may require additional headers.

Step 2: The Video and Data Protocols

Step 2 The Video and Data Protocols

// =================
// ViewController.h
// =================

@interface ViewController : UIViewController <ANVDataEventListener, ANVVideoEventListener>

@end
// =================
// ViewController.m
// =================

// Video event callback
- (void) onVideoEvent:(ANVVideoEvent)event bundle:(ANVEventBundle *)bundle {
    switch ( event ) {
        case ANV_VIDEO_EVENT_AD_STARTED:
            NSLog(@"Advertisement has started.");
            break;
        default:
            break;
    }
}

// Data event callback
- (void) onDataEvent:(ANVDataEvent)event bundle:(ANVEventBundle *)bundle {
    switch ( event ) {
        case ANV_DATA_EVENT_ADOBEPASS_INIT_SUCCESS:
            NSLog(@"Adobe Pass Initialization successful.");
            break;
        default:
            break;
    }
}

Anvato TvOS SDK, communicates with the application using two callback methods defined in ANVVideoEventListener and ANVDataEventListener protocols. For notifying video events such as Video Started, Video Paused, Video Resumed, the SDK fires the onVideoEvent method defined in ANVVideoEventListener. The SDK specifies the type of the event and provides ANVEventBundle object that provides additional details about the event. For example, if an AdBreak is detected, the bundle contains information such as the number of ads and their individual lengths. Similarly, for events that occur entitlement checks and program changes in live stream, SDK fires onDataEvet method defined in ANVDataEventListener. Therefore, you application needs to implement these two delegate functions.

Step 3: Initialize ANVConfig and ANVSDK objects

These parameters allows Anvato backend to identify your application and start the SDK with a default configuration that this specific to your application. Once the ANVConfig object is created, the application can change the default values and finalize the SDK configuration. The next section explains SDK configuration in detail.

Then, using the AppKey and SecKey pair, you should initialize the Anvato Config object. If the method returns nil that indicates a problem, either the values are not correct or there is a network problem which hinder the application to communicate with the Anvato backend services.

The implementation starts with constructing an instance of ANVConfig object using your AppKey and SecKey pairs using initWithAppKey:secKey static method.

In order to construct the Anvato TvOS SDK, you will need to have an instance of a class that have implemented ANVVideoEventListenerand ANVDataEventListeners protocols. Having ViewController as the event listener is a good practice. In the sample that we provide, we follow the same approach. When the protocol object is ready, you may simply create the Anvato TvOS SDK, by simply pass it to the SDK's initializer function. It is also another good practice to check if the SDK is properly constructed or not, simply by checking the returned object.

When the SDK is ready, you can simply start a new video by passing a video ID to the SDK. In most cases, this is the MCP Video ID.

Step 3

// =================
// ViewController.m
// =================

-(BOOL) createANVSDKandPlay {
    NSString *appKey = @"APP_KEY";
    NSString *secKey = @"SEC_KEY";
    NSString *videoID = @"YOUR_MCPID";

    // First create an instance of the ANVConfig object. Using this object, you can set your parameters before creating an instance of the SDK      
    ANVConfig *anvCfg = [[ANVConfig alloc] initWithAppKey:YOUR_APP_KEY secKey:YOUR_SEC_KEY];
    if ( !anvCfg ) {
        NSLog(@"ERROR: Unable to init ANVConfig. Problem with key pair?");
        return NO;
    }

    self.anvSDK = [[ANVSDK alloc] initWithDataEventListener:self withVideoEventListener:self];
    if (!self.anvSDK) {
        NSLog(@"ERROR: Unable to init ANVPlayerSDK. Config not properly initialized?");
        return NO;
    }

    [self.anvSDK initPlayerWithViewController:self];
    [self.anvSDK.video load:videoID withType:ANV_VIDEO_TYPE_MCP];
    return YES;
}

Configuring the SDK

ANVConfig

// Accessing to singleton instance of the Anvato Configuration Object
[ANVConfig sharedInstance]

ANVConfig object provides an interface for the appplication for multiple purposes including

ANVPlaybackOptions

ANVPlaybackOptions *options = [ANVPlaybackOptions new];

ANVPlaybackOptions object provides an interface for the appplication to provide more optional information to the SDK before calling the video to be played. It also allows the application to pass data regarding an a content being played or extra custom metadata to be sent with analytics pings.

Plugins

This section describes all the available plugins that can be configured and initialized using the Anvato TvOS SDK.

DFP

Description

The Anvato TvOS SDK supports DoubleClick for Publishers, DFP, an advertisement software as a service application run by Google. Application can set DFP settings before using load to play video by using the APIs in the dfp namespace of the AnvatoConfig instance. Anvato TvOS SDK will use these settings in the post object which is used to get video data from backend servers.

There are two type of DFP ad: server side dfp and client side dfp. We highly recommend using the server side dfp, since it cannot be blocked by ad blockers.

Client Side

// Sets the DFP in the Anvato SDK active
[ANVConfig sharedInstance].dfp.isActive = YES;

// Sets the DFP client side in the Anvato SDK active
[ANVConfig sharedInstance].dfp.client.isActive = YES;

// Only one of the following options should be set.
// Option 1: Set the ad preroll url
[ANVConfig sharedInstance].dfp.client.adTagUrl = @"adTagUrl";

// Option 2: Set the ad play list url, which includes preroll url and postroll url
[ANVConfig sharedInstance].dfp.client.playListUrl = @"playListUrl";

Configuration Parameters

Parameter Name Type Description
isActive BOOL Indicates if DFP is enabled or not.
client ANVDFPAdConfig DFP client ad configuration.
client.adTagUrl NSString The DFP ad preroll url.
client.isActive BOOL Indicates if DFP client side is enabled or not.
client.playListUrl NSString The DFP ad playlist Url, including ad preroll url and ad postroll url.

Server Side

// Sets the DFP in the Anvato SDK active
[ANVConfig sharedInstance].dfp.isActive = YES;

// Sets the DFP server side in the Anvato SDK active
[ANVConfig sharedInstance].dfp.server.isActive = YES;

// Set all the other parameters.
[ANVConfig sharedInstance].dfp.server.customParams = (NSMutableDictionary*)customParamsDic;
[ANVConfig sharedInstance].dfp.server.parameters = (NSMutableDictionary*)paramsDic;
[ANVConfig sharedInstance].dfp.server.serverUrl = @"serverUrl";
[ANVConfig sharedInstance].dfp.server.userAgent = @"userAgent";

Configuration Parameters

Parameter Name Type Description
isActive BOOL Indicates if DFP is enabled or not.
server ANVDFPAdConfig DFP server ad configuration.
server.customParams NSMutableDictionary The DFP custom paramaters.
server.isActive BOOL Indicates if DFP server side is enabled or not.
server.parameters NSMutableDictionary The DFP paramaters.
server.serverUrl NSString The DFP server url.
server.userAgent NSString The DFP user agent.

Expected behavior

When the dfp is set up, ads should be able to play in the app. Also, we can observe the impressions from the proxy logs (e.g. using HTTP proxy tool such as Charles). The impressions will be fired at the ad pod start point, the ad start point, the 25% ad point, the 50% ad point, the 75% ad point and the ad finish point.

Charles of Omniture Request

Freewheel

Description

The Anvato TvOS SDK supports playback of client side and server side ads served from freewheel ad servers. By configuring the SDK with server side freewheel advertising parameters, the SDK will send the the values to the Anvato backend, which will insert the modified version of the advertisement into the original video asset and serve it to the player. Conversely, by using client side freewheel advertising parameters, the player will make an ad request and parse the VAST response by itself. The player will then play the video as a seperate play item as part of a playlist. We suggest server side ad stitching over client side since ad blockers cannot block server stitched ads.

Configuration Parameters

Through the freewheel object in ANVConfig the Application can set either the client side or server side ad stitching configuration. This can be done by accessing the client or server object of freewheel. The following sections shows how to set them.

//Activate freehweel server side ad stitching
[ANVConfig sharedInstance].freewheel.server.isActive = YES;
[ANVConfig sharedInstance].freewheel.server.network_id = @"123456";
[ANVConfig sharedInstance].freewheel.server.profile_id = @"123456:profile_anvato_ios";
[ANVConfig sharedInstance].freewheel.server.server_url = @"http:\/\/29773.s.fwmrm.net\/ad\/g\/1";
[ANVConfig sharedInstance].freewheel.server.site_section_id = @"test_anvato_app_vod_ipad";
[ANVConfig sharedInstance].freewheel.server.video_asset_id = @"ANV_ASSET_ID";

Server Side Ad Stitching Parameters

The following parameters are to be set in the AnvatoConfig object to enable server side ad stitched content to be played on the Anvato player. These parameters needs to be configured before the Anvato video load API call.

Parameter Name Type Description
isActive BOOL Enables Freewheel server side advertisement plugin.
network_id *NSString The network ID to retrieve the advertisement.
profile_id *NSString The freewheel profile ID
server_url *NSString The freewheel server URL.
site_section_id *NSString The site section ID of the freewheel ad.
video_asset_id *NSString The video asset ID to be sent to freewheel to retrieve ads targeting the particular asset.
Method Return Type Description
getDictionary NSDictionary Returns a dictionary containing the values of the freewheel server side paramters such as network_id, profile_id, server_url, site_section_id and video_asset_id.
//Activate freehweel client side ad stitching
[ANVConfig sharedInstance].freewheel.client.isActive = YES;
[ANVConfig sharedInstance].freewheel.server.server_url = @"http:\/\/29773.s.fwmrm.net\/ad\/g\/1";
[ANVConfig sharedInstance].freewheel.client.customParams = @{@"param1":@"value1",@"param2":@"value2"};
[ANVConfig sharedInstance].freewheel.client.parameters = @{@"key1":@"value1"};
[ANVConfig sharedInstance].freewheel.client.slotParamters = @{};

Client Side Ad Stitching Parameters

The following parameters are to be set in the AnvatoConfig object to enable client side ad stitched content to be played on the Anvato player. These parameters need to be configured before the Anvato video load API call. In case of client ad stitching, the player will fetch the ad by creating a URL out of the following parameters. Since the URL is called directly from the player, it can be blocked by ad blockers.

Parameter Name Type Description
isActive BOOL Enables Freewheel client side advertisement plugin.
customParams *NSMutableDictionary Custom parameters to send as part of the Freewheel ad query.
parameters *NSMutableDictionary Required list of parameters sent as part of the ad request.
server_url *NSString The freewheel server URL.
slotParameters *NSMutableArray slotParamaters is a list that is appended at the end of the URL, seperated by ';'
Method Return Type Description
getAdTagURL *NSString Returns a strng representation of the ad request URL that is created using the server_url, parameters, custom parameters and slotParameters.

Expected behavior

During playback of an advertisement fetched from freewheel, the SDK fires the ANV_VIDEO_EVENT_AD_POD_STARTED, for an ad pod and ANV_VIDEO_EVENT_AD_STARTED video event for every individual ad.We can also observe the relevant pings sent to freewheel server in a proxy tool. An image of a Ad Complete ping observed in Charles Proxy is shown below. Freewheel ad complete Call

Heartbeat

Description

The TvOS SDK implements the Adobe Heartbeat library and if this plugin in enabled, it sends relevant video, chapter, ad and quality of service metrics. During video playback, heartbeat calls are sent which contain information regarding the video being played. The plugin also allows the application to piggyback custom metadata on heartbeat calls so as to gather additional information regarding the video experience. The following sections explain the various heartbeat configuration parameters, steps to enable heartbeat plugin as well as configuring the SDK to send custom metadata on heartbeat calls.

Configuration Parameters

// Sets the Heartbeat plugin in the Anvato SDK active
[ANVConfig sharedInstance].heartbeat.isActive = YES;

// Shows verbose Debug logs. Adobe recommends debug mode be turned off for Production application
[ANVConfig sharedInstance].heartbeat.isDebugMode = YES;

[ANVConfig sharedInstance].heartbeat.channel = @"channel";
[ANVConfig sharedInstance].heartbeat.job_id = @"1";
[ANVConfig sharedInstance].heartbeat.ovp = @"ovp";
[ANVConfig sharedInstance].heartbeat.publisher = @"publisher-name";
[ANVConfig sharedInstance].heartbeat.SDK = @"1.6.6";
[ANVConfig sharedInstance].heartbeat.tracking_server = @"heartbeats.omtrdc.net ";
Parameter Name Type Description
isActive BOOL Indicates if Heartbeat is enabled or not.
isDebugMode BOOL Sets the Heartbeat library to debug mode.
channel NSString* The heartbeat channel name.
job_id NSString* The heartbeat job_id paramater.
ovp NSString* The heartbeat ovp paramater.
publisher NSString* The heartbeat publisher paramater.
sdk NSString* The heartbeat sdk version.
tracking_server NSString* Indicates the tracking server where the heartbeat calls are sent.

Application Parameters

ANVPlaybackOptions *options = [ANVPlaybackOptions new];
options.userData.mUserDataBundle = @{
                                         @"heartbeat":@{
                                            @"videoMVPD":@"Cablevision",
                                            @"videoScreen":@"fullscreen",
                                            @"videoInitiate":@"Manual"
                                         }
                                     };
// Load video with playback options
[self.anvatoSDK.video load:"videoMCPID" withType:ANV_VIDEO_TYPE_MCP withOptions:options];

The application can pass additional data to the SDK which will be sent as part of the heartbeat calls containing context metadata. This can be achieved by setting the mUserDataBundle dictionary of the userData object of the ANVPlaybackOptions. This has been demonstrated using the sample code on the side.

Events and Heartbeat Data Information

This sections maps out the events that are tracked by the Heartbeat Plugin as well as the data we send with the corresponding event. Some events like Ad Break start, Chapter start allow us to pass a context metadata dictionary along with the call. If the application passes additional data to be sent with heartbeat calls, it is attached to these dictionaries.

Events tracked by Heartbeat

Event Name Description
Video Load Load the main video asset
Video Unload Unload the main video asset
Play Playback start
Pause Playback stop/pause
Seek Start Seek start
Seek Complete Seek complete
Buffer Start Buffer start
Buffer Complete Buffer complete
Complete Playback complete
Ad Start An ad starts
Ad Complete An ad completes
Chapter Start A new chapter starts
Chapter Complete A chapter completes
Bitrate Change A switch to another bitrate occurs
Session Start Autoplay is on, or user clicks play
Application Error An error occurs at the application level

Heartbeat data information

Video Information

This information is sent by the plugin when the player first loads the video.

Parameter Custom Metadata Description
playerName YES The name of the player playing the video. Set to Anvato TvOS Player by default.
streamType YES Indicates the type of the content (e.g., 'live', 'vod', 'clip')
videoId YES Shows the MCP ID of the video asset
name YES The user friendly name of the video asset
playhead NO Current position of the video player in seconds.
length NO Duration of te asset in seconds. -1 for live

Ad Break Information

This information is sent when the player starts an advertisement block.

Parameter Custom Metadata Description
playerName YES The name of the player playing the ad. It is set to Anvato Player SDK with version information by default.
name YES Friendly name of the ad pod. (e.g., 'preroll', 'midroll')
position NO Sequence number of the ad pod in the asset.
startTime NO The offset of the ad

Ad Information

This information is sent at every advertisement start.

Parameter Custom Metadata Description
adID YES The ID of the advertisement.
name YES User friendly name of the advertisement. If this is not available, player sets it to 'N/A' by default
position NO Position of the advertisement in the ad pod starting from 1
length NO Duration of the advertisement

Chapter Information

This information is sent at the transition from advertisement to content.

Parameter Custom Metadata Description
name YES User friendly name of the chapter
length NO Duration of the chapter
position NO Position of the chapter in the asset
startTime NO The offset of the chapter in the asset in seconds

QoS Information

This information is sent in every Heartbeat call and contains details regarding the quality of video being played.

Parameter Custom Metadata Description
startUpTime NO The time it took to load the content
bitrate NO Current bitrate of the video (available only for HLS content)
fps NO Framerate of the content. By default all videos is 30 fps
droppedFrames NO Number of dropped frames by the decoder.

Expected Behaviour

The device logs can be filtered by ANVHeartbeatManager to see if heartbeat manager was enabled and successfully initialized. Also the heartbeat plugin's isDebugMode can be set to YES to see more verbose logs in order to verify what data the SDK is providing to the Adobe Heartbeat library in response to video events.

Disclaimer

Adobe Heartbeat Plugin functionality is controlled by Adobe, Inc. ("3rd Party") Anvato does not accept any responsibility for the plugin. Any technical questions regarding the full functionality of the plugin must be directed to the 3rd Party. You must both have an account with the 3rd Party and enter into a license agreement with the 3rd Party to use this plugin.

Google Analytics

Description

The Anvato apple tvOS SDK implements the Google Analytics(GA) plugin which enables it to send analytics data to the Google Analytics end point when this plugin is enabled. The SDK also allows the application to send custom metadata in these calls. The following sections describe how the GA plugin can be enabled and how the application can pass data to the SDK to be inserted in the GA calls. GA dashboards provide insights to content broadcasters by gathering key metrics during high demand events and monitor the system in real time.

Configuration Parameters

//Enables/Disables the Google Analytics plugin 
[ANVConfig sharedInstance].googleAnalytics.isActive = YES;

//Sets the Google Analytics trackerId, and custom values.
[ANVConfig sharedInstance].googleAnalytics.trackerId = @"Mandatory Tracker ID";
[ANVConfig sharedInstance].googleAnalytics.mapping.customDimension.videoSecondsViewed = 10;
[ANVConfig sharedInstance].googleAnalytics.mapping.customDimension.context = @{@"11": @"title",
                                                                    @"12":@"assetId"};
[ANVConfig sharedInstance].googleAnalytics.mapping.customMetric =  @{@"videoPlayerLoad": @21,
                                                              @"videoStart": @22};

//Sets auto Ping Time, in case no ANV_DATA_EVENT_NEW_PROGRAM for live.
[ANVConfig sharedInstance].googleAnalytics.autoPingTime = 30;
Parameter Name Type Description
isActive BOOL Indicates if Google Analytics plugin is enabled or not. (Mandatory.)
trackerId NSString* This property is used to set or get the Google Analytics tracker ID. (Mandatory.)
mapping.customDimension.videoSecondsViewed NSDictionary* Custom dimension: Video Seconds Viewed.
mapping.customDimension.context NSDictionary* Custom dimension: context.
mapping.customMetric NSDictionary* Custom metric.
autoPingTime NSInteger The waiting time for the pings when there is no ANV_DATA_EVENT_NEW_PROGRAM for live.

From the application, to start Google Analytics plugin, besides configuring the AnvatoConfig Google Analytics plugin on the SDK, the application needs to include the libGoogleAnalyticsServices.a library since Google Analytics library is weakly linked in the AnvatoSDK.

Expected behavior

Once the video starts playing, the SDK will start sending relevant Google Analytics calls for corresponding video events. We should see logs indicating whether the SDK was able to initialize Google Analytics library and make the relevant calls. Google Analytics calls will show up in a proxy tool such as Charles.

Notice statement

Google Analytics Plugin functionality is controlled by Google, LLC. You must both have an account with the Google Analytics Service and enter into a license agreement with the Google to use this plugin.

Reference Guide

SDK

The SDK can be initialized by providing it with the listeners that will receive the Data and Video Events as described in the Event Flow section. The following methods can be used to initialize the AnvatoSDK.

- (instancetype) initWithDataEventListener:(id )ANVDataEventListener withVideoEventListener:(id)ANVVideoEventListener;

- (instancetype) initWithDataEventListener:(id )ANVDataEventListener withVideoEventListener:(id)ANVVideoEventListener withData:(NSDictionary *)customData;

// Default Initialization of the Anvato SDK with data and video listeners.
self.anvatoSDK = [[ANVSDK alloc] initWithDataEventListener:self withVideoEventListener:self];
// OR
// Initializing Anvato SDK with Data, Video listeners and custom data in the form of a NSDictionary.
self.anvatoSDK = [[ANVSDK alloc] initWithDataEventListener:self withVideoEventListener:self withData:customData];

Method Parameters

Parameter Type nil Description
ANVDataEventListener ANVDataEventListener NO Instance inheritanted protocol ANVDataEventListener
ANVVideoEventListener ANVVideoEventListener NO Instance inheritanted protocol ANVVideoEventListener
customData (optional) NSDictionary NO Setting custom data

Return Value

Returns an Anvato SDK instance if successfully initialized. Returns nil if initialization failed for any reason.

- (NSDictionary *) handleCustomRequest:(NSString *)key withData:(NSDictionary *) data;

// Handling custom request
[self.anvatoSDK handleCustomRequest:key withData:data];

This is used as a custom communication channel to pass data to the SDK.

Method Parameters

Parameter Type nil Description
key NSString NO Key to add Custom Info into the dictionary.
data NSDictionary NO Custom Info to add into the dictionary

Return Value

Returns NSDictionary of the CustomInfo.

- (NSString *) getVersion;

// Getting SDK version
ANVLogd(TAG, @"| Initializing Anvato TvOS SDK: %@",[self getVersion]);

Returns the current version of the Anvato TvOS SDK.

Return Value

Returns Version Number as a String.

- (void) close;

// Closing SDK
[self.anvatoSDK close];

Closes the SDK and all the third party tools that have been initialized.

- (void) setLogLevel:(int) logLevel;

// Setting the Log Level
[self.anvatoSDK.video setLogLevel:0];

Sets the Anvato Log Level, so the log verbosity can be changed. 0 represents the highest verbosity while 5 will mute all logs from the SDK. Setting the logger to 4 will show only fatal errors.

Method Parameters

Parameter Type nil Description
logLevel int NO The desired log level between 0-5.

Video API

- (BOOL) load:(NSString *)videoInfo withType:(ANVVideoType)videoType;

// Loading MCP Video
NSString videoID = @"[MCP_ID]";
[self.anvatoSDK.video load:videoID withType:ANV_VIDEO_TYPE_MCP];

//Loading External Video
NSString *videoURL = @"http://www.anvato.com/sample/bigBuckBunny.m3u8";
NSDictionary *videoInfo = @{@"url":videoURL,@"isVOD":@NO,@"video_format": @"hls"};
[self.anvatoSDK.video load:[ANVUtilFunc Dictionary2JSONStr:videoInfo] withType:ANV_VIDEO_TYPE_MCP_DIRECT];

This Video API call starts loading the requested video. The Video ID is provided along with the video type. Values for video type include 'ANV_VIDEO_TYPE_MCP', 'ANV_VIDEO_TYPE_MCP_DIRECT', 'ANV_VIDEO_TYPE_URL', 'ANV_VIDEO_TYPE_VPAID' and 'ANV_VIDEO_TYPE_UNKNOWN'.

Method Parameters

Parameter Type nil Description
videoInfo NSString NO If type is ANV_VIDEO_TYPE_MCP videoInfo is set to MCP ID.
Otherwise, it is set to JSON String that defines the video information
videoType ANVVideoType NO On of the parameters in ANVVideoType enum defined in ANVGlobals.h

- (BOOL) load:(NSString )videoInfo withType:(ANVVideoType)videoType withOptions:(ANVPlaybackOptions ) options;

// Loading MCP Video
NSString videoID = @"3058548";

// Set required playback options
ANVPlaybackOptions *options = [ANVPlaybackOptions new];
options.video.startFromInSec = 2038;

// Load the video with options
[self.anvatoSDK.video load:videoID withType:ANV_VIDEO_TYPE_MCP withOptions:options];

The Anvato SDK can also use the above method to start loading a video with a given videoType and additional playback options. The ANVPlaybackOptions class defines various video, content properties like allowing the application to set the starting point of playing a VOD, the initial volume of the player, etc. The PlaybackOptions also allows the Application to pass a dictionary to the SDK that can be used by the SDK to procure furter information not available to it. This can be done using the mUserDataBundle dictionary of the userData property of ANVPlaybackOptions.

Method Parameters

Parameter Type nil Description
videoID NSString NO If type is ANV_VIDEO_TYPE_MCP videoInfo is set to MCP ID.
Otherwise, it is set to JSON String that defines the video information
videoType ANVVideoType NO One of the parameters in ANVVideoType enum defined in ANVGlobals.h
options ANVPlaybackOptions YES Additional information to be provided to the Anvato SDK before loading the video.

Return Value

Returns YES if the parameters are NO, false otherwise.

Events Triggered

Type Name Description
DATA ANV_DATA_EVENT_VIDEO_LOAD_SUCCESS Indicates that video load is successful.
DATA ANV_DATA_EVENT_VIDEO_LOAD_FAIL Indicates that video load has failed.

- (BOOL) pause

When called, the SDK attempts to pause video playback.

// Requests the Anvato player to pause playback.
[self.anvatoSDK.video pause];

Return Value

Returns YES if video is currently playing. Otherwise, it will return NO.

Events Triggered

Type Name Description
VIDEO ANV_VIDEO_EVENT_PAUSED Indicates that video has been paused.

- (BOOL) resume

When called, the SDK attempts to resume video playback.

// Resume the video playback.
[self.anvatoSDK.video resume];

Return Value

Returns YES if video is currently paused. Otherwise, it will return NO.

Events Triggered

Type Name Description
VIDEO ANV_VIDEO_EVENT_RESUMED Indicates that video has been resumed.

- (BOOL) seek:(CMTime) time

When called, the SDK attempts to seek the video to the specified time.

// Seeking MCP Video to 120 sec.
[self.anvatoSDK.video seek:CMTimeMake(120, 1)];

Method Parameters

Parameter Type nil Description
time CMTime NO Time in seconds

Return Value

Returns YES if video is successfully sought . Otherwise, it will return NO.

Events Triggered

Type Name Description
VIDEO ANV_VIDEO_EVENT_SEEK_REQUESTED Indicates that video seek is requested.

- (BOOL) stop

When called, the SDK attempts to stop video playback.

// Stop current playback
[self.anvatoSDK.video stop];

Return Value

Returns YES if video is currently stopped. Otherwise, it will return NO.

- (void) setVolume:(float) level

When called, the SDK attempts to set video volume.

// Setting Video Volume
[self.anvatoSDK.video setVolume:self.mVolumeSlider.value];

Method Parameters

Parameter Type nil Description
volume float NO The audio level between 0.0 and 1.0

- (float) getVolume

When called, the SDK attempts to return video volume value.

// Getting current player volume
self.mVolumeSlider.value = [self.anvatoSDK.video getVolume];

Return Value

Returns a float value which is the audio level between 0.0 and 1.0.

- (BOOL) mute

When called, the SDK attempts to mute video playback.

// Muting current video
[self.anvatoSDK.video mute];

Return Value

Returns YES if video is muted. Otherwise, it will return NO.

Events Triggered

Type Name Description
VIDEO ANV_VIDEO_EVENT_MUTE Indicates that video has been muted.

- (BOOL) unmute

When called, the SDK attempts to unmute video playback.

// Unmuting MCP Video
[self.anvatoSDK.video unmute];

Return Value

Returns YES if video is unmuted. Otherwise, it will return NO.

Events Triggered

Type Name Description
VIDEO ANV_VIDEO_EVENT_UNMUTE Indicates that video has been unmuted.

- (NSDictionary*) getStateUpdate

When called, the SDK attempts to get the states of the video playback.

// Get state from SDK
NSDictionary *dictionary = [self.anvatoSDK.video getStateUpdate];

Return Value

Returns NSDictionary of the states.

Events Triggered

Key KeyType ValueTpye Description
playerType NSString NSString Describeing the player type. It is “native” for TvOS player.
numAds NSString Integer Number of ads in an ad-pod (available only during ads.
adIndex NSString Integer Position of the ad in an ad-pod (available only during ads).
adPodDur NSString Integer Duration of the ad pod (available only during ads).
playerName NSString NSString Formed as “ANV SDK Player:[SDK_VERSION]”.
state NSString NSString Describes that state of the video player. Possible values are [“idle” “buffering”, “paused”, “playing”].
videoType NSString NSString Describes the type of the video. Possible values are “vod” for VOD content and “live” for linear streams.
playHeadTime NSString Integer Current playback position of the player in seconds.
duration NSString Integer Duration of the content in seconds.
isAd NSString BOOL TRUE if add is playing FALSE otherwise.

Anvato TvOS v4 Release Notes

Version 1.0

Server Side and Client Side Ad Stitched VOD

Application can specify freewheel/dfp parameters and play a Server/Client side stitched VOD. These ads are also tracked and related impressions are fired by the SDK.

AnvatoRT plugin added

The AnvatoSDK is able to send crucial analytics information using the AnvatoRT analytics plugin enabled in the SDK.