1--- 2title: Digital rights management 3--- 4 5ExoPlayer uses Android's [`MediaDrm`][] API to support DRM protected playbacks. 6The minimum Android versions required for different supported DRM schemes, along 7with the streaming formats for which they're supported, are: 8 9| DRM scheme | Android version number | Android API level | Supported formats | 10|---------|:------------:|:------------:|:---------------------| 11| Widevine "cenc" | 4.4 | 19 | DASH, HLS (FMP4 only) | 12| Widevine "cbcs" | 7.1 | 25 | DASH, HLS (FMP4 only) | 13| ClearKey "cenc" | 5.0 | 21 | DASH | 14| PlayReady SL2000 "cenc" | AndroidTV | AndroidTV | DASH, SmoothStreaming, HLS (FMP4 only) | 15 16In order to play DRM protected content with ExoPlayer, the UUID of the DRM 17system and the license server URI should be specified 18[when building a media item]({{ site.baseurl }}/media-items.html#protected-content). 19The player will then use these properties to build a default implementation of 20`DrmSessionManager`, called `DefaultDrmSessionManager`, that's suitable for most 21use cases. For some use cases additional DRM properties may be necessary, as 22outlined in the sections below. 23 24### Key rotation ### 25 26To play streams with rotating keys, pass `true` to 27`MediaItem.DrmConfiguration.Builder.setMultiSession` when building the media 28item. 29 30### Multi-key content ### 31 32Multi-key content consists of multiple streams, where some streams use different 33keys than others. Multi-key content can be played in one of two ways, depending 34on how the license server is configured. 35 36##### Case 1: License server responds with all keys for the content ##### 37 38In this case, the license server is configured so that when it receives a 39request for one key, it responds with all keys for the content. This case is 40handled by ExoPlayer without the need for any special configuration. Adaptation 41between streams (e.g. SD and HD video) is seamless even if they use different 42keys. 43 44Where possible, we recommend configuring your license server to behave in this 45way. It's the most efficient and robust way to support playback of multikey 46content, because it doesn't require the client to make multiple license requests 47to access the different streams. 48 49##### Case 2: License server responds with requested key only ##### 50 51In this case, the license server is configured to respond with only the key 52specified in the request. Multi-key content can be played with this license 53server configuration by passing `true` to 54`MediaItem.DrmConfiguration.Builder.setMultiSession` when building the media 55item. 56 57We do not recommend configuring your license server to behave in this way. It 58requires extra license requests to play multi-key content, which is less 59efficient and robust than the alternative described above. 60 61### Offline keys ### 62 63An offline key set can be loaded by passing the key set ID to 64`MediaItem.DrmConfiguration.Builder.setKeySetId` when building the media item. 65This allows playback using the keys stored in the offline key set with the 66specified ID. 67 68{% include known-issue-box.html issue-id="3872" description="Only one offline 69key set can be specified per playback. As a result, offline playback of 70multi-key content is currently supported only when the license server is 71configured as described in Case 1 above." %} 72 73### DRM sessions for clear content ### 74 75Use of placeholder `DrmSessions` allows `ExoPlayer` to use the same decoders for 76clear content as are used when playing encrypted content. When media contains 77both clear and encrypted sections, you may want to use placeholder `DrmSessions` 78to avoid re-creation of decoders when transitions between clear and encrypted 79sections occur. Use of placeholder `DrmSessions` for audio and video tracks can 80be enabled by passing `true` to 81`MediaItem.DrmConfiguration.Builder.forceSessionsForAudioAndVideoTracks` when 82building the media item. 83 84### Using a custom DrmSessionManager ### 85 86If an app wants to customise the `DrmSessionManager` used for playback, they can 87implement a `DrmSessionManagerProvider` and pass this to the 88`MediaSource.Factory` which is [used when building the player]. The provider can 89choose whether to instantiate a new manager instance each time or not. To always 90use the same instance: 91 92~~~ 93DrmSessionManager customDrmSessionManager = 94 new CustomDrmSessionManager(/* ... */); 95// Pass a drm session manager provider to the media source factory. 96MediaSource.Factory mediaSourceFactory = 97 new DefaultMediaSourceFactory(dataSourceFactory) 98 .setDrmSessionManagerProvider(mediaItem -> customDrmSessionManager); 99~~~ 100{: .language-java} 101 102### Improving playback performance ### 103 104If you're experiencing video stuttering on a device running Android 6 to 11 when 105playing DRM protected content, you can try [enabling asynchronous buffer 106queueing]. 107 108[main demo app]: {{ site.release_v2 }}/demos/main 109[`MediaDrm`]: {{ site.android_sdk }}/android/media/MediaDrm.html 110[used when building the player]: {{ site.baseurl }}/media-sources.html#customizing-media-source-creation 111[enabling asynchronous buffer queueing]: {{ site.baseurl }}/customization.html#enabling-asynchronous-buffer-queueing 112