Exoplayer and ProgressBar
in layout file:
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"/>
in player activity:
player.addListener(new ExoPlayer.EventListener() {
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {}
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {}
@Override
public void onLoadingChanged(boolean isLoading) {}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_BUFFERING){
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.INVISIBLE);
}
}
@Override
public void onPlayerError(ExoPlaybackException error) {}
@Override
public void onPositionDiscontinuity() {}
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {}
});
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.