I'm new to Android Studio and ExoPlayer I started the player to play videos but I don't know to detect if the player is buffering and show a progress bar to notify the user, any help please?
you can simply change XML attribute show_buffering if you are using Exoplayer2. Also see PlayerView. setShowBuffering(PlayerView. ShowBuffering) for more details.
The YouTube app and many more Google’s video streaming apps use the ExoPlayer to stream and play videos. ExoPlayer is a media player library that provides a way to play media with lots of customization in your android app.
ExoPlayer is highly customizable and extensible, making it capable of many advanced use cases. It supports a variety of media formats, including adaptive formats such as DASH and SmoothStreaming. Note: Read more about the pros and cons in the ExoPlayer developer guide. Moderate knowledge of Android development and Android Studio
But ExoPlayer was introduced in Android API level 16 i.e. the Android Jelly Bean. So, you can't use ExoPlayer for API less than 16. But this is not a matter to worry about.
Almost 100% (99.2%, to be more precise) of Android devices present on the Play Store have API level 16 or more, so you can say that almost all Android devices present on Play Store, supports ExoPlayer. The video played in the MediaPlayer does not support the smooth streaming. Also, there was no support for adaptive playbacks like DASH and HSL.
Maybe it will be helpful to someone:
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
app:show_buffering="true"/>
you can simply change XML attribute show_buffering if you are using Exoplayer2.
Also see PlayerView.setShowBuffering(PlayerView.ShowBuffering)
for more details.
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