Skip to main content
Skip table of contents

Multi-instance

To test this feature and view the example code, please see the Apple (FPS) SDK 5 Example Code Quick Start guide.

The CONNECT Player SDK for FPS supports multiple instances of OTVAVPlayer being created and used simultaneously. This allows features such as the main stream playback to be shown whilst a preview window of another stream is shown to the user.

To use multiple players for clear streams, create two players and attach each to its own AVPlayerLayer (or OTVContainerView). By doing this, you will get independent playback and control for each player.

Multi-instance playback for encrypted streams is slightly more complex, requiring additional information from the license delegate.

Procedure

Example code of multiple player instance support can be found in the multi-instance folder (or UnifiedExampleCode written in SwiftUI).

In the ViewController class (or Multi Instance model class in UnifiedExampleCode), the example code shows how to set up the license delegate and provide the SSP token to it and how to set the license delegate to OTVDRMManager or OTVAVPlayer instance. The example has two encrypted streams with different stream tokens used to fetch the licence.

To support the playback of multiple encrypted streams on multiple players simultaneously, two instances of license delegate are created to handle the license requests for each player differently.

  • For the first player instance, the license delegate is set to OTVDRMManager by calling OTVDRMManager.shared.setLicenseDelegate(delegate) and the same procedure as only one player instance can be followed.

  • For the second player instance, the player MUST be constructed with let player = OTVPlayer() and the second license delegate MUST be set to player by calling player.setLicenseDelegate(delegate) before playing any stream.

The way of setting delegate to player can also be used for only one player instance, which can achieve the same goal as calling OTVDRMManager.shared.setLicenseDelegate(delegate).

When zapping, for each player, the token of the string MUST be set before the stream is set to player. The following code demonstrates the sequence:

CODE
licenseDelegate.setHTTPHeader(parameters: ["nv-authorizations": token])
player.replaceCurrentItem(with: OTVAVPlayerItem(url: streamUrl))
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.