6

I have video in my project. and for security i encrypt the video files which is working quite well. but problem is that the

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

In this method I have to pass the file.(which is decrypted) so I am creating decrypted file on sdcard for path of file is that possible to pass bytes (which are decrypted) directly in video view. I am using Cipher for encrypt.

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(); 
}
4

2 回答 2

3

如果您正在寻找将视频流式传输到没有中间文件来存储解密版本的 VideoView,那么答案是肯定的,您可以做到。您需要两个主要组件:一个流服务器,例如本地 http 实例和CipherInputStream

于 2013-03-27T20:55:54.837 回答
0

我怀疑你能做到。由于您使用的是 VideoView,因此需要特定的标头和尾端来说明哪种格式以及如何编码等。如果您能弄清楚我仍然怀疑它是否可以采用原始文件。您最好的选择是创建随机文件名,同时保存并将其传递给播放器。

于 2012-06-09T07:42:27.090 回答