@@ -31,23 +31,28 @@ internal class DrmMediaSourceHelperImpl @Inject constructor(private val secureSt
3131 MediaItem .Builder ()
3232 .setUri(request.url)
3333 .apply {
34- // Apply DRM config if content is DRM-protected
35- request.drmInfo?.let { drmInfo ->
36- MediaItem .DrmConfiguration .Builder (drmInfo.drmType.toExoplayerConstant())
37- .setLicenseUri(drmInfo.licenseServer)
38- .setLicenseRequestHeaders(drmInfo.drmHeaders)
39- .apply {
40- // If the content is a download content, use the saved offline DRM key id.
41- // This ID is needed to retrieve the local DRM license for content decryption.
42- if (isDownload) {
43- secureStorage.getDrmDownload(context = context, id = id, drmType = drmInfo.drmType)?.let { drmDownload ->
44- setKeySetId(drmDownload.drmKeyId)
45- } ? : throw DrmPlaybackException (IllegalStateException (" No DRM key id saved for download content" ))
34+ try {
35+ // Apply DRM config if content is DRM-protected
36+ request.drmInfo?.let { drmInfo ->
37+ MediaItem .DrmConfiguration .Builder (drmInfo.drmType.toExoplayerConstant())
38+ .setLicenseUri(drmInfo.licenseServer)
39+ .setLicenseRequestHeaders(drmInfo.drmHeaders)
40+ .apply {
41+ // If the content is a download content, use the saved offline DRM key id.
42+ // This ID is needed to retrieve the local DRM license for content decryption.
43+ if (isDownload) {
44+ secureStorage.getDrmDownload(context = context, id = id, drmType = drmInfo.drmType)?.let { drmDownload ->
45+ setKeySetId(drmDownload.drmKeyId)
46+ } ? : throw DrmPlaybackException (IllegalStateException (" No DRM key id saved for download content" ))
47+ }
4648 }
47- }
48- .build()
49- }?.let { drmConfig ->
50- setDrmConfiguration(drmConfig)
49+ .build()
50+ }?.let { drmConfig ->
51+ setDrmConfiguration(drmConfig)
52+ }
53+ } catch (ex: DrmPlaybackException ) {
54+ // attempt to load unencrypted, there's a chance the user supplied excessive DRMInfo. An exception will
55+ // be raised elsewhere if this content can't be decrypted.
5156 }
5257 }
5358 .build()
0 commit comments