BB Native Player SDK public project homepage
with Native Player SDK for iOS
In Xcode, create a new iOS project using Objective-C or Swift. Use BBNativePlayerExample as the project name.
Note CocoaPods: version 8.64 is the last version on CocoaPods and gets no further updates. Move to Swift Package Manager; the migration guide has the steps.
Swift Package Manager (SPM) is integrated into Xcode and packages can be added directly to a project through the Xcode UI. For more information on adding packages, see the Apple documentation. The package needs iOS 14.0 or later. It brings the shared module, Google IMA, Google User Messaging Platform and Google Cast, so you do not add those yourself.
Note The names of buttons and menu items may vary slightly between Xcode versions.
https://github.com/bluebillywig/bbnativeplayerkit-cocoapod. This shows the bbnativeplayerkit-cocoapod package.BlueBillywigNativePlayerKit-iOS: Google Cast with Bluetooth.BlueBillywigNativePlayerKit-iOS-NoBluetooth: Google Cast without Bluetooth.Set Add to Target to your app target for the product you pick, and to None for the other one.
Note Add exactly one product, never both. Each one contains its own copy of Google Cast. If your app uses Google Cast without Bluetooth, pick the
-NoBluetoothproduct. The<version>-no-bluetoothbranches are deprecated and 8.64 is the last version that gets one. Pinned to such a branch? Switch to the-NoBluetoothproduct with Exact Version 8.63.2 or later, or a version rule that floats.
The name bbnativeplayerkit-cocoapod dates from when CocoaPods was the first dependency manager we supported. The repository is the Swift package with the compiled BBNativePlayerKit framework.
<key>NSLocalNetworkUsageDescription</key>
<string>${PRODUCT_NAME} needs local area network access for google chromecast device discovery.</string>
<key>NSBonjourServices</key>
<array>
<string>_lnp._tcp</string>
<string>_googlecast._tcp</string>
<string>_1F61A3A5._googlecast._tcp</string>
</array>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices.</string>
<key>NSMicrophoneUsageDescription</key>
<string>${PRODUCT_NAME} uses microphone access to listen for ultrasonic tokens
when pairing with nearby Cast devices.</string>
Please change the the strings starting with “${PRODUCT_NAME}” so they are appropriate for your app.
If you use the BlueBillywigNativePlayerKit-iOS-NoBluetooth product, omit the Bluetooth strings.
Next, add the BBNativePlayerKit framework to the ViewController using an import statement beneath the existing imports.
import UIKit
import BBNativePlayerKit
import bbnativeshared
class ViewController: UIViewController {
In the ViewOnLoad method in the ViewController add the following code to create a BBPlayerView and add it to the current view. Use your own embed url as jsonUrl parameter
private var bbPlayerView: BBNativePlayerView? = nil
override func viewDidLoad() {
super.viewDidLoad()
// create player view using the embed url
bbPlayerView = BBNativePlayer.createPlayerView(uiViewController: self, frame: view.frame, jsonUrl: "https://bb.dev.bbvms.com/p/default/c/1092747.json")
// add player to the view
view.addSubview(bbPlayerView!)
// use constraints to place and size the player view
bbPlayerView?.translatesAutoresizingMaskIntoConstraints = false
bbPlayerView?.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true
bbPlayerView?.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0 ).isActive = true
bbPlayerView?.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor).isActive = true
bbPlayerView?.heightAnchor.constraint(equalToConstant: view.safeAreaLayoutGuide.layoutFrame.width * 9/16).isActive = true
}
override func viewDidLoad() {
.
.
.
.
// set class to delegate of player view
bbPlayerView?.delegate = self
}
We will implement the delegate in an extension. You don’t have to use an extension but it keeps your code organized
Just a few methods are implemented here as an example. See the documentation for a full list.
extension ViewController: BBNativePlayerViewDelegate {
func bbNativePlayerView(didTriggerPlaying playerView: BBNativePlayerView) {
print("Blue Billlywig Player: didTriggerPlaying")
}
func bbNativePlayerView(didTriggerPause playerView: BBNativePlayerView) {
print("Blue Billlywig Player: didTriggerPause")
}
}
For more information and example code, check out our demo app at https://github.com/bluebillywig/bbnativeplayerkit-demo