I am looking for good and simple example/explanation how to implement ExoPlayer
for HLS Adaptive
streaming. I am a newbie and do not have experience and knowledge so I can figure how to do this from code example on git.
There are too many 'moving parts' so beginner can understand and reuse it in own projects.
Can somebody help me to learn and understand how to use/implement ExoPlayer
in order to achieve this functionality?
Thanks!
The easiest way to get started using ExoPlayer is to add it as a gradle dependency. You need to make sure you have the jcenter repository included in the build.gradle file in the root of your project:
repositories { jcenter() }
Next, include the following in your module's build.gradle file:
compile 'com.google.android.exoplayer:exoplayer:r2.2.0'
1. Your Layout File
2. Your Class File(Activity)
I think this is enough for beginner. Also keep in mind that this library's standard audio and video components rely on Android’s MediaCodec API, which was released in Android 4.1 (API level 16). So it will not work on android 4.0 and below.
Don't forget to add this permission to the
manifest file
:<uses-permission android:name="android.permission.INTERNET"/>
The answer from @Vicky will work, but has one flaw.
The bandwidth meter that you pass to the track selector must be the same one that the datasource factory uses. The data source factory maintains the bandwidth estimate by calling the BW meter methods, and the adaptive track selection process gets the estimate to decide which track to adapt to.
If they are not the same instance, the adaptive selection always gets -1 as the BW, and picks some middle ground option.
The demo ExoPlayer apps also have this flaw. They pass false to the useBwMeter in buildDataSource(), which means no updating of the BW estimate EDIT: Actually, this BW meter is for the manifest loader. It does not need to use the BW meter.