Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I play a DES encrypted File using ExoPlayer

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);
    }
like image 823
Adam W Avatar asked Feb 05 '15 17:02

Adam W


Video Answer


1 Answers

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.

like image 91
Mike Sokolov Avatar answered Nov 15 '22 00:11

Mike Sokolov