PlayKitSmartSwitch 1.2.0

PlayKitSmartSwitch 1.2.0

Maintained by Oren Melamed, Sergey Chausov, Nilit Danan, Noam Tamim, Gilad Nadav, Kaltura.



 
Depends on:
PlayKit/AnalyticsCommon~> 3.30
KalturaPlayer/Interceptor>= 0
KalturaNetKit~> 1.7.0
 

  • By
  • Kaltura

PlayKitSmartSwitch

Swift 3.0+ CI Status Version License Platform

Kaltura Player iOS plugin for NPAW Smart Switch

Example

To run the example project, clone the repo, and run pod install from the Example directory. Then run iOS and tvOS samples

Installation

PlayKitSmartSwitch is available through CocoaPods. To install it, simply add the following lines to your Podfile:

pod 'PlayKitSmartSwitch'

Once you setup everything run command in the Terminal.

pod install

Usage

In the AppDelegate:

This step required only for basic PlayKit users.

import PlayKit
import PlayKitSmartSwitch

in the application(_:didFinishLaunchingWithOptions:) needs to add registration plugin to PlayKit manager:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
PlayKitManager.shared.registerPlugin(SmartSwitchMediaEntryInterceptor.self)
return true
}

Create plugin config and add it to player:

Create plugin config parameters may be different than shown on example.

import PlayKit
import KalturaPlayer
import PlayKitSmartSwitch
var kalturaOTTPlayer: KalturaOTTPlayer

let smartSwitchConfig = SmartSwitchConfig()
smartSwitchConfig.accountCode = "kalturatest" // Youbora account code.
smartSwitchConfig.originCode = "vod"
smartSwitchConfig.optionalParams = ["live": "false"]
smartSwitchConfig.timeout = 5 // Timeout time period for Youbora CDN balancer calls.
smartSwitchConfig.reportSelectedCDNCode = true // if true plugin will report chosen CDN code to Youbora analytics.
// smartSwitchUrl this is optional parameter. Set it if you have different Youbora CDN balancer host.
smartSwitchConfig.smartSwitchUrl = "http://cdnbalancer.youbora.com/orderedcdn"

// Add PluginConfig to KalturaPlayer
let playerOptions = PlayerOptions()
playerOptions.pluginConfig = PluginConfig(config: [SmartSwitchMediaEntryInterceptor.pluginName: smartSwitchConfig])

kalturaOTTPlayer = KalturaOTTPlayer(options: playerOptions)

You may need to update player with new options if needed.

kalturaOTTPlayer.updatePlayerOptions(playerOptions)

Errors handling

On the kalturaOTTPlayer object you have to subscribe to an event SmartSwitchEvent.error to recieve errors rised by plugin.

kalturaOTTPlayer.addObserver(self, events: [SmartSwitchEvent.error]) { event in
            // Handle Smart Switch error here.
            if let error = event.error {
                // error here is NSError
                print(error.localizedDescription)
            }
        }

License and Copyright Information

All code in this project is released under the AGPLv3 license unless a different license for a particular library is specified in the applicable library path.

Copyright © Kaltura Inc. All rights reserved.
Authors and contributors: See GitHub contributors list.