I need to play video when onBindViewHolder() is called and then if the item is scrolled down or top, I need to stop that video. How to do it in RecyclerView's adapter?
I need to play video when onBindViewHolder() is called and then if the item is scrolled down or top, I need to stop that video. How to do it in RecyclerView's adapter?
You can override onViewAttachedToWindow(VH holder) and onViewDetachedFromWindow(VH holder) methods in your adapter. Then start and stop the video in their body. As documentation said:
onViewAttachedToWindowis called when a view created by this adapter has been attached to a window.
onViewDetachedFromWindowis called when a view created by this adapter has been detached from its window.
Here I found some links for you :
You can understand the concept after seeing these links.
For your question I just google that play pause video in recylcerview android and I hope next time you will do same things as I do.
Note: Everything is not possible to write in comment so I wrote as an answer.
Thank you.