我的项目中有视频。为了安全起见,我加密了运行良好的视频文件。 但问题是
**videoView.setVideoPath("/mnt/sdcard/intro_video.3gp");**
在这种方法中,我必须传递文件。(已解密) 所以我在 sdcard 上为文件路径创建解密文件是可以直接在视频 View 中传递字节(已解密)。我正在使用 Cipher 进行加密。
这是我的代码
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();
}
最佳答案
如果在没有中间文件的情况下将视频流式传输到 VideoView 来存储解密版本是您正在寻找的,那么答案是肯定的,您可以做到。您需要两个主要组件:一个流媒体服务器,例如本地 http 实例和 CipherInputStream .
关于android - 我怎样才能在android中播放来自byte的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10959103/