PlayerConfiguration Class

@objc
public class PlayerConfiguration : NSObject, Codable

This is the structure that describes the player configuration for a single asset

ClearKey usage:

guard let url = URL(string: "STREAM-URL") else {
    return
}

let playerConfiguration(with: url, contentType: .hls)
guard let player =  PRESTOplaySDK.shared.playerForContent(playerConfiguration) else {
    print("no player")
    return
}

Fairplay usage:

guard let url = URL(string: "STREAM-URL") else {
    return
}

let playerConfiguration(with: url, contentType: .hls)
playerConfiguration.drmSystem = .fairplay
playerConfiguration.drmConfiguration = DrmConfiguration()
playerConfiguration.drmConfiguration.environment = .production
playerConfiguration.drmConfiguration.userId = "..."
playerConfiguration.drmConfiguration.sessionId = "..."
playerConfiguration.drmConfiguration.merchant = "..."
playerConfiguration.drmConfiguration.assetId = "..."
playerConfiguration.drmConfiguration.variantId = "..."

guard let player =  PRESTOplaySDK.shared.playerForContent(playerConfiguration) else {
    print("no player")
    return
}

Custom RequestModifier usage:

Example showing custom Fairplay URLs

guard let url = URL(string: "STREAM-URL") else {
    return
}

let playerConfiguration(with: url, contentType: .hls)
playerConfiguration.drmSystem = .fairplay
playerConfiguration.drmConfiguration = DrmConfiguration()
playerConfiguration.drmConfiguration.licensingUrl = URL(string: "LICENSING-URL"
playerConfiguration.drmConfiguration.certificateUrl = URL(string: "CERTIFICATE-URL")

// implement custom request modifier to add headers and intercept
// the request
 PRESTOplaySDK.shared.requestModifiers.append(RequestModifier())
 PRESTOplaySDK.shared.responseModifiers.append(ResponseModifier())

guard let player =  PRESTOplaySDK.shared.playerForContent(playerConfiguration) else {
    print("no player")
    return
}

Public

  • Configuration to control the algorithm for quality switching.

    Remark

    not available for PlayerEngine.apple.

    Remark

    Must be set before calling open.

    Declaration

    Swift

    public var abrConfiguration: AbrConfiguration?
  • In case of a downloaded stream, this field will point to the url from which the stream was downloaded.

    Declaration

    Swift

    public var originUrl: URL?
  • CLPlayer uses two different players under the hood: PlayerEngine.apple (currently based on AVPlayer) and PlayerEngine.castLabs (currently based on VideoToolbox).

    Certain formats are only playable by one of those while others are supported by both.

    • HLS+Fairplay, MP3: only PlayerEngine.apple
    • DASH, SmoothStreaming: only PlayerEngine.castLabs
    • HLS, HLS+ClearKey, MP4: both This flag instructs what player engine is used for the common formats.

    When choosing the engine please pay attention what features you want to support as some of them are only available on one of them.

    • PlayerEngine.apple supports: Airplay, Picture in Picture.
    • PlayerEngine.castLabs supports: Widevine, ABR settings and other custom features (refers to the methods in PlayerAPI for the complete list).

    Declaration

    Swift

    public var preferredEngine: PlayerEngine?