Reproducing encrypted video using ExoPlayer

前端 未结 5 1912
心在旅途
心在旅途 2020-12-07 22:51

I\'m using ExoPlayer, in Android, and I\'m trying to reproduce an encrypted video stored locally.

The modularity of ExoPlayer allows to create custom components tha

5条回答
  •  时光取名叫无心
    2020-12-07 23:47

    Eventually I found the solution.

    I used a no-padding for the encryption algorithm, in this way:

    cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC");
    

    so that the size of the encrypted file and the clear file size remain the same. So now I created the stream:

    cipherInputStream = new CipherInputStream(inputStream, cipher) {
        @Override
        public int available() throws IOException {
             return in.available();
        }
    };
    

    This is because the Java documentation says about ChiperInputStream.available() that

    This method should be overriden

    and actually I think is it more like a MUST, because the values retrieved from that method are often really strange.

    And that is it! Now it works perfectly.

提交回复
热议问题