# PlayerConfiguration Class

    @objc
    public class PlayerConfiguration : NSObject, NSCopying, 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

- `networkConfiguration`

  Configuration to control network behaviour.

  #### Declaration

  Swift

      public var networkConfiguration: NetworkConfiguration?

- `cmcdConfiguration`

  Configuration to control CMCD behaviour.

  Remark

  HLS configuration for HLS streaming is limited to header based data.

  Remark

  It is enough to set the default configuration to enable CMCD.

  #### Declaration

  Swift

      public var cmcdConfiguration: CmcdConfiguration?

- `abrConfiguration`

  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?

- `originUrl`

  In case of a downloaded stream, this field will point to the url from which the stream was downloaded.

  Note

  Required for offline playback of protected content.

  #### Declaration

  Swift

      public var originUrl: URL?

- `preferredEngine`

  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?