videoView在播放时在不保存的情况下播放CipherOutputStream

时间:2019-07-14 10:42:34

标签: java android

我试图将文件编码并保存到sd(我做了这部分) 现在我想播放outputstream(解码时)而不保存文件,还能够查找视频..怎么?这里是解码代码。

OR

使用缓存播放解码的输出流。

  class VideoTask extends AsyncTask<String, Integer, String> {
    File outfile;
    File decfile;    File decfileORI;
    FileInputStream encfis;Cipher decipher;
    FileOutputStream decfos;
    int read;
    CipherOutputStream cos;

    public downloadpage that;
    public VideoTask(downloadpage joinAsync)throws FileNotFoundException, NoSuchPaddingException, NoSuchAlgorithmException {

        this.that=joinAsync;

    }



    @Override
    protected void onPreExecute() {
        super.onPreExecute();

      //  Toast.makeText(that, "TASK STARTED", Toast.LENGTH_SHORT).show();
      //  Toast.makeText(that, "sdadasd  "+ that.originalKey , Toast.LENGTH_LONG).show();
    }

    @Override
    protected String doInBackground(String... strings) {////////////////////////////////////////////////
       try {


            outfile = new File("/sdcard/bus_encode.mp4");//GET
            decfile = new File("/sdcard/bus_FinisH.mp4");//DECODE AND GIVE
            encfis = new FileInputStream(outfile);
            decfos = new FileOutputStream(decfile);
            decipher = Cipher.getInstance("AES");
           decipher.init(Cipher.DECRYPT_MODE, that.originalKey);
            cos = new CipherOutputStream(decfos, decipher);
         //  Toast.makeText(that, "length" + vid_size, Toast.LENGTH_SHORT).show();
           int c=0;

           byte[] b = new byte[8*1024];
           while (((read = encfis.read(b)) != -1)&&(c<10000)) {//c mahdudiyat video
               cos.write(b,0,read);
               cos.flush();c++;
           }
           cos.close();
       }catch (Exception e){}////////////////////////////////////////////////////////////
        return null;
    }

    @Override
    protected void onPostExecute(String s) {
        super.onPostExecute(s);
       // Toast.makeText(that, "finished DECODING. enjoy :)", Toast.LENGTH_LONG).show();
that.GoToVid();
    }
}

0 个答案:

没有答案