How can I encrypt a DES file using ExoPlayer

I use ExoPlayer to play media files (mp4s.h264 encoded) from the device’s SD card. Some of the DES files are encrypted. I can decrypt the files and return an inputStream, but then I am not sure how to play this input stream using ExoPlayer. Any help would be greatly 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); } 
+6
source share
1 answer

You can write your own DataSource that accepts an InputStream: for a DataSource, you simply implement open (DataSpec), close () and read (byte [] buffer, int offset, int readLength). What amazes me is that there is no implementation in ExoPlayer. It would seem that this is an obvious blade for their Swiss army knife.

+1
source

Source: https://habr.com/ru/post/982061/


All Articles