including the following in your project's build.gradle file:
where rX.X.X is the your preferred version. For the latest version, see the project's Releases. For more details, see the project on Bintray.
Main steps to play video & audio using the standard TrackRenderer implementations
Instantiate your ExoPlayer:
To play audio only you can use these values:
Both buffer values can be tweaked according to your requirements.
Now you have to create a DataSource. When you want to stream mp3 you can use the DefaultUriDataSource. You have to pass the Context and a UserAgent. To keep it simple play a local file and pass null as userAgent:
Then create the sampleSource:
uri points to your file, as an Extractor you can use a simple default Mp3Extractor if you want to play mp3. requestedBufferSize can be tweaked again according to your requirements. Use 5000 for example.
Now you can create your audio track renderer using the sample source as follows:
Finally call prepare on your exoPlayer instance:
To start playback call:
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0