How can I play video from a byte in android

I have a video in my project. and for security, I encrypt video files that work quite well. but the problem is that

**videoView.setVideoPath("/mnt/sdcard/intro_video.3gp");** 

In this method I have to transfer the file (which is decrypted) so I create the decrypted file on sdcard for the path to the file - this is the ability to transfer bytes (which are decrypted) directly in the form of video. I use cipher for encryption.

Here is my code for

  private void decryption()throws Exception { // TODO Auto-generated method stub String filePath2 = path + "en/encVideo"; String filePath3 = path + "de/decVideo"; File decfile = new File(filePath3); if(!decfile.exists()) decfile.createNewFile(); File outfile = new File(filePath2); int read; FileInputStream encfis = new FileInputStream(outfile); Cipher decipher = Cipher.getInstance("AES"); decipher.init(Cipher.DECRYPT_MODE, skey); FileOutputStream decfos = new FileOutputStream(decfile); CipherOutputStream cos = new CipherOutputStream(decfos,decipher); while((read=encfis.read()) != -1) { cos.write(read); cos.flush(); } cos.close(); } 
+6
source share
2 answers

I doubt you will. Since you are using VideoView, this will require certain headers and tails that suggest what format and how it is encoded, etc. If you can understand that I still doubt that he can take the raw file. It would be best to create random file names by saving and passing them to the player.

0
source

If streaming video to VideoView without an intermediate file to store the decrypted version is what you are looking for, then the answer is "Yes, you can do it." You need two main components: a streaming server, such as a local HTTP instance, and CipherInputStream .

+3
source

Source: https://habr.com/ru/post/917671/


All Articles