3

I use the following FrameWorkSampleSource Constructor to initialize SampleSource instance.

File file = new File(path);
FileInputStream inputStream = new FileInputStream(file);
FileDescriptor fd = inputStream.getFD();
SampleSource sampleSource = new FrameworkSampleSource(fd, 0, file.length());

But I need to play an InputStream using ExoPlayer. I am unable to find any interface that implements SampleSource class and takes InputStream as a parameter in its constructor.

Hugo Gresse
  • 17,195
  • 9
  • 77
  • 119
Aman Mahajan
  • 153
  • 1
  • 10

1 Answers1

3

It seems that there is no easy way to achieve this, because ExoPlayer is not designed for this. To quote the developer:

"We do not provide an implementation that wraps an InputStream directly because the InputStream interface doesn't provide suitable random access behavior for media playback, which is required both for seeking and because some media formats place data at the end of the file that must be read at the start of playback."

Read his full answer here:

https://github.com/google/ExoPlayer/issues/1086

mismor
  • 605
  • 4
  • 13