Kaltura Player iOS 插件用于 NPAW Smart Switch
要运行示例项目,克隆仓库,并在 Example 目录中运行 pod install
。然后运行 iOS 和 tvOS 示例
PlayKitSmartSwitch 可通过 CocoaPods 获取。要安装,只需将以下行添加到您的 Podfile
pod 'PlayKitSmartSwitch'
一切设置完成后,在终端中运行命令。
pod install
此步骤仅适用于基本 PlayKit 用户。
import PlayKit
import PlayKitSmartSwitch
在 application(_:didFinishLaunchingWithOptions:)
中需要向 PlayKit 管理器添加插件注册
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
PlayKitManager.shared.registerPlugin(SmartSwitchMediaEntryInterceptor.self)
return true
}
创建插件配置参数可能与示例中显示的不同。
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)
如果需要,您可能需要使用新选项更新播放器。
kalturaOTTPlayer.updatePlayerOptions(playerOptions)
在 kalturaOTTPlayer
对象上,您需要订阅事件 SmartSwitchEvent.error
以接收插件引发的错误。
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)
}
}
此项目的所有代码都发布在 AGPLv3 许可下,除非特定库在适用库路径中指定了不同的许可证。
版权 © Kaltura Inc。保留所有权利。
作者和贡献者:请参阅 GitHub 贡献者列表。