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);
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With