How to play partial mp4 file in android

大城市里の小女人 提交于 2019-12-08 09:12:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!