Kaltura Player iOS plugin for NPAW Smart Switch
To run the example project, clone the repo, and run pod install
from the Example directory.
Then run iOS and tvOS samples
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
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 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)
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)
}
}
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.