How do I play a DES encrypted File using ExoPlayer
Asked Answered
R

1

8

I am using ExoPlayer to play Media files(mp4s .h264 encoded) from the SD card of a device. Some of the files are DES encrypted. I can decrypt the files and get back an inputStream, but then I am unsure of how to play this inputStream using ExoPlayer. Any help would be appreciated.

protected void playVideo(File file) {
        InputStream is;
        if (file.getName().endsWith(".DES")) {
            is = FileManager.decryptFile(file);
            //what to do with this input stream?
        }

        Uri uri = Uri.parse(file.getAbsolutePath());

        if (mPlayer != null) {
            mPlayer.release();
        }

        mPlayer = new VideoPlayer(getRendererBuilder(uri));
        mPlayer.addListener(this);
        if (mLastPosition > 0) {
            mPlayer.seekTo(mLastPosition);
        }

        mPlayer.prepare();
        mPlayer.setSurface(mSurface);
        mPlayer.setPlayWhenReady(true);
    }
Rags answered 5/2, 2015 at 17:30 Comment(2)
InputStream should be written into a temporary file, which will be actually played by ExoPlayer. I am trying the same thing, but the problem is that it takes a lot of time to decryptFile. Did you found a solution for passing InputStream itself to Exo?Aubervilliers
I never did find a solution to this. We implemented encryption on the whole SD card when it is mounted/unmounted using encfs. I still would like to figure this out because I believe it is part of a better solution but haven't had time to really delve further into it.Rags
C
1

You can write a custom DataSource that accepts an InputStream: for DataSource, you just implement open(DataSpec), close(), and read(byte[] buffer, int offset, int readLength). What astonishes me is that there doesn't seem to be any implementation already available in ExoPlayer. It would seem like an obvious blade for their swiss army knife.

Cestode answered 11/12, 2015 at 11:37 Comment(3)
There was implementation, but they hided it github.com/google/ExoPlayer/blob/master/library/src/main/java/…Sanderlin
@RogerAlien link brokenRags
@AdamW gist.github.com/AlienAsRoger/a0011d246d83c3823d73fcc5bb6a44d6 programcreek.com/java-api-examples/…Sanderlin

© 2022 - 2024 — McMap. All rights reserved.