Seeking forward/backward issue using libmedia library

I have used libmedia library (library version 2) to play encrypted videos at runtime. Using the library there is an issue with seeking forward/backward. My videos are stored on http server like I have a video of 24 mins. of duration and when I seek the playing video through seekbar of media controller it takes very long time to reach to seek position and I will have to wait for that. For your information, I have implemented the code for seeking with forward/backward tolerance which is provided in libeasy-libmedia documentation page.

I have used MyCipherFactory class :

private class MyCipherFactory implements LocalSingleHttpServer.CipherFactory{

        @Override
        public Cipher getCipher() throws GeneralSecurityException {
        // you are free to choose your own Initialization Vector
            byte[] initialIV = new byte[16];
            return rebaseCipher(initialIV);
        }

        @Override
        public Cipher rebaseCipher(byte[] iv) throws GeneralSecurityException {
        // avoid the default security provider "AndroidOpenSSL" as of Android 4.3
            Cipher c = Cipher.getInstance("AES/CTR/NoPadding", "BC");
            c.init(Cipher.DECRYPT_MODE,
                new SecretKeySpec(AppUtils.SECURITY_KEY.getBytes(), "AES"),
                new IvParameterSpec(iv));
            return c;
        }
    }

After that I used an object of this class like this :

LocalSingleHttpServer mServer = new LocalSingleHttpServer();
mServer.setCipherFactory(new MyCipherFactory());
mServer.start();

And I stop the server wherever is required.

Did I miss anything in seek video implementation or the code is as per documentation ?

Please help me out for this issue.


Source: android

Leave a Reply