问题
i am stuck in a weird situation, as i am developing an android app which decrypts video at run time and plays it. Decryption process is already optimized and i am using RC4 algorithm and nio channel for copying but problem is that, it still takes about 1 min 10 secs for 250mb video and my client wants it maximum 15 secs. I am thinking about a solution in which i play my video while its getting decrypted and copy but its not happening i am getting error can't play this video. I am using VideoView to play videos. Anybody have any idea, how to achieve this. I am setting my video uri using
v.setVideoURI(uri);
I can play video if i am playing once its decrypted.
Please help me out.
回答1:
Of course, willing to decrypt the entire video before to start playing exposes the user to a noticeable delay. You should consider a streaming architecture.
A typical design involves the javax.crypto.CipherInputStream class and a local http instance. There is no class for an http server in the SDK, you have to implement your own one, otherwise look for an existing library similar to LocalSingleHttpServer.
It looks like:
mServer = new LocalSingleHttpServer();
mServer.setCipher(myGetCipher());
mServer.start();
path = mServer.getURL(path);
mVideoView.setVideoPath(path);
mVideoView.start();
来源:https://stackoverflow.com/questions/29470858/how-to-play-partial-mp4-file-in-android