我的项目中有video。 为了安全起见,我加密了运行良好的video文件。 但问题在于
**videoView.setVideoPath("/mnt/sdcard/intro_video.3gp");**
在这个方法中,我必须传递文件。(这是解密的)所以我在sdcard上创建解密文件的文件路径是可以直接在video视图中传递字节(解密)。 我正在使用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,因此需要特定的标题和尾部,以确定哪种格式以及如何编码等。如果您能够弄清楚我仍然怀疑它可以采用原始文件。 您最好的选择是在保存并将其传递给播放器时创建随机文件名。
如果将video流式传输到VideoView而没有中间文件来存储解密版本就是您正在寻找的,那么答案是肯定的,您可以这样做。 您需要两个主要组件:流式服务器,如本地http实例和CipherInputStream 。