I am trying to implement a list with videos like vine or Instagram app. Where they play video plays when list item is shown or fully visible and video pauses when list item
Why don't you add the custom video view in the layout file 'view_main' itself. Check the visibility of the video view and play only if the view is visible.
public static boolean isViewVisible(View subView, View parentView) {
Rect scrollBounds = new Rect();
parentView.getHitRect(scrollBounds);
if (subView.getLocalVisibleRect(scrollBounds)) {
return true;
}
return false;
}
Code for checking visiblity. Call this in scroll state changed listener when the scroll state is idle.
Also you will have to use an AsyncTask for downloading videos ,but only download one video at a time or you might get out of memory error.