Skip to content

Kaltura Player iOS plugin for Broadpeak SmartLib

License

Notifications You must be signed in to change notification settings

kaltura/playkit-ios-broadpeak-smartlib

Repository files navigation

PlayKitBroadpeak

Swift 5.0+ CI Status

Kaltura Player iOS plugin for Broadpeak SmartLib

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

PlayKitBroadpeak is not published to main CocoaPods Specs repo, but you can manage it via CocoaPods tools. To install it, simply add the following lines to your Podfile:

# Cocoapods sources
source 'https://github.com/CocoaPods/Specs.git'
# Broadpeak Cocoapods sources
source 'https://delivery-platform.broadpeak.tv/ios/broadpeak/specs.git'
pod 'PlayKitBroadpeak', :git => 'https://github.com/kaltura/playkit-ios-broadpeak-smartlib', :tag => 'v1.0.1' # Make sure this is the latest one!
pod 'SmartLib-v3/Generic', '03.02.05.3568' # Make sure this is the latest one!

Then, you will need to add our repository and install pods:

pod repo add broadpeak https://delivery-platform.broadpeak.tv/ios/broadpeak/specs.git

Once you setup everything run command

pod install

Original installation guide for iOS and tvOS Broadpeak SmartLib.

Follow the steps of how to add Broadpeak repo to CocoaPods on your Mac.

iOS & tvOS

Usage

In the AppDelegate:

import PlayKit
import PlayKitBroadpeak

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(BroadpeakMediaEntryInterceptor.self)
return true
}

Create plugin config and add it to player:

Create plugin config parameters can be different than shown on example, it depends on your integration with Broadpeak.

import PlayKit
import KalturaPlayer
import PlayKitBroadpeak
var kalturaOTTPlayer: KalturaOTTPlayer

let bpConfig = BroadpeakConfig()
bpConfig.analyticsAddress = ""
// Set nanoCDNHost only if you are using the Broadpeak nanoCDN device, othervise set an empty string ""
bpConfig.nanoCDNHost = ""
bpConfig.broadpeakDomainNames = "*"

// Add PluginConfig to KalturaPlayer
let playerOptions = PlayerOptions()
playerOptions.pluginConfig = PluginConfig(config: [BroadpeakMediaEntryInterceptor.pluginName: bpConfig])
        
kalturaOTTPlayer = KalturaOTTPlayer(options: playerOptions)

It is possible to update player with new options if needed.

kalturaOTTPlayer.updatePlayerOptions(playerOptions)

iOS 14 and local network privacy:

Since iOS 14, the system requires a specific permission to allow the nanoCDN discovery used by SmartLib.

Make your declaration

Bonjour services
Declare the nanoCDN service name “_nanocdn._tcp” in your app’s Info.plist.

<key>NSBonjourServices</key>
<array>
<string>_nanocdn._tcp</string>
</array>

Provide context

Privacy - Local Network Usage Description
After declaring this service, you also need to provide a reason string, which provides context to someone when your app attempts to access a local network. Make sure this text clearly explains what your app is doing with the information it discovers from the local network and how receiving this data enables a necessary experience in your app.

<key>NSLocalNetworkUsageDescription</key>
<string>Description example</string>

Additional resouces

Protect privacy during device discovery
Support local network privacy in your app

Errors handling

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

kalturaOTTPlayer.addObserver(self, events: [BroadpeakEvent.error]) { event in
            // Handle Broadpeak SmartLib 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.