# Module: ProtectionController

Provides access to media protection information and functionality. Each
ProtectionController manages a single `MediaPlayer.models.ProtectionModel`
which encapsulates a set of protection information (EME APIs, selected key system,
key sessions). The APIs of ProtectionController mostly align with the latest EME
APIs. Key system selection is mostly automated when combined with app-overrideable
functionality provided in `ProtectionKeyController`.

Source:
  - streaming/protection/controllers/ProtectionController.js, line 51
To Do:
  - ProtectionController does almost all of its tasks automatically after init() is called. Applications might want more control over this process and want to go through each step manually (key system selection, session creation, session maintenance). This module can be accessed using the MediaPlayer API getProtectionController()

### Methods

#### handleKeySystemFromManifest()

  Once all mediaInfo objects have been added to our mediaInfoArray we can select a key system or check if the kid has changed and we need to trigger a new license request

  Source:
    - streaming/protection/controllers/ProtectionController.js, line 137

#### initializeForMedia( [mediaInfo])

  Initialize this protection system for a given media type.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `mediaInfo` | StreamInfo | <optional> | Media information

  Source:
    - streaming/protection/controllers/ProtectionController.js, line 118

#### setMediaElement(element)

  Associate this protection system with the given HTMLMediaElement. This
  causes the system to register for needkey/encrypted events from the given
  element and provides a destination for setting of MediaKeys

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `element` | HTMLMediaElement | the media element to which the protection system should be associated

  Source:
    - streaming/protection/controllers/ProtectionController.js, line 518

#### setRobustnessLevel(level)

  Sets the robustness level for video and audio capabilities. Optional to remove Chrome warnings.
  Possible values are SW_SECURE_CRYPTO, SW_SECURE_DECODE, HW_SECURE_CRYPTO, HW_SECURE_CRYPTO, HW_SECURE_DECODE, HW_SECURE_ALL.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `level` | string | the robustness level

  Source:
    - streaming/protection/controllers/ProtectionController.js, line 549

#### setServerCertificate(serverCertificate)

  Sets a server certificate for use by the CDM when signing key messages
  intended for a particular license server. This will fire
  an error event if a key system has not yet been selected.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `serverCertificate` | ArrayBuffer | a CDM-specific license server certificate

  Source:
    - streaming/protection/controllers/ProtectionController.js, line 503

  ##### Fires:

  - ProtectionController#event:ServerCertificateUpdated

#### setSessionType(value)

  Sets the session type to use when creating key sessions. Either "temporary" or
  "persistent-license". Default is "temporary".

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | string | the session type

  Source:
    - streaming/protection/controllers/ProtectionController.js, line 537

#### stop()

  Stop method is called when current playback is stopped/resetted.

  Source:
    - streaming/protection/controllers/ProtectionController.js, line 574

#### Search results