Reputation: 173
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.
Upvotes: 3
Views: 2954
Reputation: 605
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
Upvotes: 3