Java Code Examples for com.google.android.exoplayer2.drm.DrmSession#DrmSessionException
The following examples show how to use
com.google.android.exoplayer2.drm.DrmSession#DrmSessionException .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalDrmSessionManager.java From no-player with Apache License 2.0 | 6 votes |
@SuppressWarnings("PMD.AvoidCatchingGenericException") // We are forced to catch Exception as ResourceBusyException is minSdk 19 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) @Override public DrmSession<FrameworkMediaCrypto> acquireSession(Looper playbackLooper, DrmInitData drmInitData) { DrmSession<FrameworkMediaCrypto> drmSession; try { SessionId sessionId = SessionId.of(mediaDrm.openSession()); FrameworkMediaCrypto mediaCrypto = mediaDrm.createMediaCrypto(sessionId.asBytes()); mediaDrm.restoreKeys(sessionId.asBytes(), keySetIdToRestore.asBytes()); drmSession = new LocalDrmSession(mediaCrypto, keySetIdToRestore, sessionId); } catch (Exception exception) { drmSession = new InvalidDrmSession(new DrmSession.DrmSessionException(exception)); notifyErrorListener(drmSession); } return drmSession; }
Example 2
Source File: LocalDrmSessionManager.java From no-player with Apache License 2.0 | 5 votes |
private void notifyErrorListener(DrmSession<FrameworkMediaCrypto> drmSession) { final DrmSession.DrmSessionException error = drmSession.getError(); handler.post(new Runnable() { @Override public void run() { eventListener.onDrmSessionManagerError(error); } }); }
Example 3
Source File: RendererErrorMapper.java From no-player with Apache License 2.0 | 5 votes |
@SuppressWarnings({"PMD.StdCyclomaticComplexity", "PMD.CyclomaticComplexity", "PMD.ModifiedCyclomaticComplexity", "PMD.NPathComplexity"}) static NoPlayer.PlayerError map(Exception rendererException, String message) { if (rendererException instanceof AudioSink.ConfigurationException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_CONFIGURATION_ERROR, message); } if (rendererException instanceof AudioSink.InitializationException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_INITIALISATION_ERROR, message); } if (rendererException instanceof AudioSink.WriteException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_WRITE_ERROR, message); } if (rendererException instanceof AudioProcessor.UnhandledFormatException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_UNHANDLED_FORMAT_ERROR, message); } if (rendererException instanceof AudioDecoderException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_DECODER_ERROR, message); } if (rendererException instanceof MediaCodecRenderer.DecoderInitializationException) { MediaCodecRenderer.DecoderInitializationException decoderInitializationException = (MediaCodecRenderer.DecoderInitializationException) rendererException; String fullMessage = "decoder-name:" + decoderInitializationException.decoderName + ", " + "mimetype:" + decoderInitializationException.mimeType + ", " + "secureCodeRequired:" + decoderInitializationException.secureDecoderRequired + ", " + "diagnosticInfo:" + decoderInitializationException.diagnosticInfo + ", " + "exceptionMessage:" + message; return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.INITIALISATION_ERROR, fullMessage); } if (rendererException instanceof MediaCodecUtil.DecoderQueryException) { return new NoPlayerError(PlayerErrorType.DEVICE_MEDIA_CAPABILITIES, DetailErrorType.UNKNOWN, message); } if (rendererException instanceof SubtitleDecoderException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.DECODING_SUBTITLE_ERROR, message); } if (rendererException instanceof UnsupportedDrmException) { return mapUnsupportedDrmException((UnsupportedDrmException) rendererException, message); } if (rendererException instanceof DefaultDrmSessionManager.MissingSchemeDataException) { return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.CANNOT_ACQUIRE_DRM_SESSION_MISSING_SCHEME_FOR_REQUIRED_UUID_ERROR, message); } if (rendererException instanceof DrmSession.DrmSessionException) { return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.DRM_SESSION_ERROR, message); } if (rendererException instanceof KeysExpiredException) { return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.DRM_KEYS_EXPIRED_ERROR, message); } if (rendererException instanceof DecryptionException) { return new NoPlayerError(PlayerErrorType.CONTENT_DECRYPTION, DetailErrorType.FAIL_DECRYPT_DATA_DUE_NON_PLATFORM_COMPONENT_ERROR, message); } if (rendererException instanceof MediaCodec.CryptoException) { return mapCryptoException((MediaCodec.CryptoException) rendererException, message); } if (rendererException instanceof IllegalStateException) { return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.MEDIA_REQUIRES_DRM_SESSION_MANAGER_ERROR, message); } return new NoPlayerError(PlayerErrorType.UNKNOWN, DetailErrorType.UNKNOWN, message); }
Example 4
Source File: PlayerActivity.java From ExoPlayer-Offline with Apache License 2.0 | 4 votes |
private DrmSessionManager<FrameworkMediaCrypto> buildOfflineDrmSessionManager(UUID uuid, String licenseUrl, Map<String, String> keyRequestProperties) throws UnsupportedDrmException, IOException, DrmSession.DrmSessionException, InterruptedException { if (Util.SDK_INT < 18) { return null; } customDrmCallback = new CustomDrmCallback( DemoApplication.getAppInstance().buildHttpDataSourceFactory(new DefaultBandwidthMeter()), licenseUrl ); DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = new DefaultDrmSessionManager<>(uuid, FrameworkMediaDrm.newInstance(uuid), customDrmCallback, null, mainHandler, eventLogger); String offlineAssetKeyIdStr = DemoApplication.getAppInstance(). getSharedPreferences().getString(DemoApplication.KEY_OFFLINE_OFFSET_ID,DemoApplication.EMPTY); byte[] offlineAssetKeyId = Base64.decode(offlineAssetKeyIdStr, Base64.DEFAULT); this.offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(customDrmCallback, null); Pair<Long, Long> remainingSecPair = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineAssetKeyId); Log.e(TAG," License remaining Play time : "+remainingSecPair.first+", Purchase time : "+remainingSecPair.second); if(DemoApplication.EMPTY.equals(offlineAssetKeyIdStr) || ( remainingSecPair.first == 0 || remainingSecPair.second == 0)) { String path = getIntent().getStringExtra(EXTRA_OFFLINE_URI); File file = getUriForManifest(path); Uri uri = Uri.fromFile(file); InputStream is = new FileInputStream(file); Log.e(TAG, "will start download now"); offlineAssetKeyId = offlineLicenseHelper.download( DemoApplication.getAppInstance().buildHttpDataSourceFactory(new DefaultBandwidthMeter()).createDataSource(), new DashManifestParser().parse(uri, is)); Pair<Long, Long> p = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineAssetKeyId); Log.e(TAG, "download done : " + p.toString()); SharedPreferences sharedPreferences = DemoApplication.getAppInstance().getSharedPreferences(); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(DemoApplication.KEY_OFFLINE_OFFSET_ID, Base64.encodeToString(offlineAssetKeyId, Base64.DEFAULT)); editor.commit(); } drmSessionManager.setMode(DefaultDrmSessionManager.MODE_QUERY,offlineAssetKeyId); return drmSessionManager; }