Android能播放字节流视频吗,我如何在android中从byte播放video

我的项目中有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 。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值