ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Encrypted video play

Open vishal105 opened this issue 8 years ago • 1 comments

How to play encrypted video in Exoplayer?

I used AES/ECB/Nopadding encryption I tried below code for playing file

DATA SOURCE CODE

DataSource.Factory factory = new DataSource.Factory() { @Override public DataSource createDataSource() { DataSource dataSource = new EncryptedFileDataSource(finalCipher, new TransferListener() { @Override public void onTransferStart(EncryptedFileDataSource source, DataSpec dataSpec) { Log.d(TAG, "onTransferStart: source" + source + "dataspec" + dataSpec); } @Override public void onBytesTransferred(EncryptedFileDataSource source, int bytesTransferred) { Log.d(TAG, "onBytesTransferred: source" + source + "bytestransferred" + bytesTransferred); } @Override public void onTransferEnd(EncryptedFileDataSource source) { Log.d(TAG, "onTransferEnd: source" + source); } }); return dataSource; } };

CIPHER CODE

final Cache cache = new SimpleCache(context1.getCacheDir(), new NoOpCacheEvictor()); final Key secretKey = new SecretKeySpec(AppConstants.videoEncryptionKey.getBytes(), ALGORITHM); Cipher cipher = null; try { cipher = Cipher.getInstance(TRANSFORMATION); cipher.init(Cipher.DECRYPT_MODE, secretKey); } catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchPaddingException e) { e.printStackTrace(); }

video file load in player But it take to much time.

I am using 2.7.0 Exoplayer library.

vishal105 avatar Feb 23 '18 08:02 vishal105

Ultimately, if whatever code you're using to load the media correctly implements ExoPlayer's DataSource interface, then content should/will play correctly. Your issue is probably with EncryptedFileDataSource, but since this isn't part of the ExoPlayer library it's not something we can really help with. You'll have to ask the author of that class for assistance.

The only type of encryption we support directly with library components is AES/CTR/NoPadding, for which you can use AesCipherDataSource.

ojw28 avatar Feb 25 '18 19:02 ojw28