Ketan Parmar
Ketan Parmar

Reputation: 43

Add progressbar loader when Video is loading in Exoplayer

By default exoplayer is not showing this progress loader on video while it is loading. I have tried many codea but not working.

Upvotes: 3

Views: 5012

Answers (2)

KJ Newtown
KJ Newtown

Reputation: 347

Use this method from the PlayerView class:

 setShowBuffering(boolean showBuffering)

/**

  • Sets whether a buffering spinner is displayed when the player is in the buffering state. The
  • buffering spinner is not displayed by default.
  • @param showBuffering Whether the buffering icon is displayer */

It is also an attribute that you can set in the XML layout: show_buffering

EDIT 2021
As mentionned below by @Rohaitas Tanoli the code above is now deprecated. Here is the updated code:

setShowBuffering(PlayerView.SHOW_BUFFERING_ALWAYS)

Upvotes: 5

Asif Ahmed
Asif Ahmed

Reputation: 11

Use app:show_buffering in layout file and values are
never = The buffering view is never shown.
always = The buffering view is always shown when the player is in the buffering state.
when_playing=The buffering view is shown when the player is in the buffering state and playWhenReady is true.

Here is the link https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/ui/PlayerView.html#SHOW_BUFFERING_WHEN_PLAYING

Upvotes: 1

Related Questions