Skip to main content

Bitmovin iOS SDK

Bitmovin iOS SDK is a native video player for iOS/iPadOS/tvOS, created and maintained by Bitmovin.

Compatibility with Bitmovin iOS SDK and QUANTEEC plugin

The QUANTEEC plugin has been tested with Bitmovin iOS SDK on iOS/tvOS devices from version 15.6 to version 18.

Add QUANTEEC plugin as a package (using Swift Package Manager)

The QUANTEEC plugin is available as a package that can be added to your project using the Swift Package Manager. To add the QUANTEEC plugin to your project, follow these steps:

  1. Open your Xcode project.
  2. Select your project in the Project Navigator.
  3. Select the target you want to add the package to.
  4. Go to the "Package Dependencies" tab.
  5. Click the "+" button to add a new package.
  6. Enter the URL of the QUANTEEC plugin repository: https://github.com/dngroup/quanteec_ios_package. You need to have linked your github account to your Xcode account.
  7. The packages "quanteec_plugin_package" and the dependency "GDCWebServer" should appear on the left panel under "package dependencies".

Install QUANTEEC in your application for Bitmovin iOS SDK

3 steps:

1- Import the QUANTEEC plugin:

import QuanteecBitmovin
import QuanteecPlugin

2- Create a QuanteecPlugin plugin configuration (QuanteecConfig). The constructor of the QuanteecPlugin required the quanteecKey as a parameter:

let quanteecConfig = QuanteecConfig(quanteecKey: "<your-quanteec-key>")
quanteecConfig.videoID = "<your-custom-videoID>"
info

To create a new QUANTEEC configuration and/or retrieve your default QUANTEEC key, you must first go to the Config page of your panel.

warning

In your QUANTEEC configuration, remember to set a different videoID if you have different formats of the same stream (e.g., one DASH stream and one HLS stream) or two variants of the same stream (one stream with English audio and one stream with another language).

Click here to find more informations on videoID

3- Create a QuanteeciOSPluginBitmovin instance. The constructor of the QuanteecPlugin required the quanteecConfig and the AVPlayer instance as parameters:

let quanteecPlugin = QuanteeciOSPluginBitmovin(quanteecConfig: quanteecConfig, player: bitmovinPlayer)

Here is a complete example of how to use the QUANTEEC plugin with AVPlayer inside a basic Swift View component:


import UIKit
import BitmovinPlayer
import QuanteecBitmovin
import QuanteecPlugin

class BitmovinViewController: UIViewController {

@IBOutlet weak var videoView: UIView!

// Bitmovin instance
let player: Player

// Quanteec plugin
let quanteecPlugin: QuanteeciOSPluginBitmovin

// stream URL
let urlString = "https://example.com/master.m3u8"


init() {
let playerConfig = PlayerConfig()
playerConfig.key = "<your-bitmovin-player-key>"

player = PlayerFactory.createPlayer(
playerConfig: playerConfig
)

QuanteecConfig.configure(quanteecKey: "<your-quanteec-key>")
QuanteecConfig.shared.videoID = "<your-custom-videoID>"
quanteecPlugin = QuanteeciOSPluginBitmovin(player: player)
super.init(nibName: String(describing: BitmovinViewController.self), bundle: Bundle.main)
}

@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()
loadVideoWithBitmovin()
}

func loadVideoWithBitmovin() {
// Create the HLS stream URL
guard let streamUrl = URL(string: urlString) else {
return
}

// Create a SourceConfig
let sourceConfig = SourceConfig(url: streamUrl, type: .hls)

// Create a Source from the SourceConfig
let source = SourceFactory.createSource(from: sourceConfig)

player.load(source: source)

// Create a PlayerView
let playerView = PlayerView(player: player, frame: videoView.bounds)

// Depending on your App layout you might want to set the autoresizingMask (recommended)
playerView.autoresizingMask = [.flexibleHeight, .flexibleWidth]

// Adding the view to the a container View
videoView.addSubview(playerView)
videoView.bringSubviewToFront(playerView)
player.mute()
player.play()
}
}
tip

Good practice: try-catch block

One good practice is to encapsulate the instantiation of the QUANTEEC object within a try-catch block. This approach provides a robust mechanism for handling situations where QUANTEEC might not be available or may encounter compatibility issues.

Error handling

Embedding QUANTEEC in an iOS app involves configuring and initializing the QUANTEEC plugin instance. If any issues arise during this process, such as missing dependencies or runtime errors, a try-catch block allows you to catch and handle these errors gracefully.

Unusual environments

iOS devices and versions vary, and not all devices may support certain features or configurations of QUANTEEC. Wrapping the QUANTEEC initialization in a try-catch block allows you to account for scenarios where certain features might not be available on the user's device or where there are compatibility issues with the iOS version.