Encrypted video play
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
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.
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.