Reputation: 664
the video which is playing on webview iframe and webview is set on recycler card view. Many videos are their on recyclerview.
I want to pause the playing video when user start scrolling recycler and pause the playing video when user play another video.
see the code
public void onBindViewHolder(final ViewHolder holder, final int position) {
holder.webView.getSettings().setUseWideViewPort(true);
holder.webView.getSettings().setLoadWithOverviewMode(true);
holder.webView.getSettings().setSupportZoom(true);
holder.webView.getSettings().setBuiltInZoomControls(true);
holder.webView.getSettings().setDisplayZoomControls(false);
holder.webView.getSettings().setJavaScriptEnabled(true);
holder.webView.loadData("<iframe src=\"https://www.youtube.com/embed/" + video_id.get(position) + "?rel=0&showinfo=0\" width=\"1280\" height=\"720\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" allowFullScreen=\"true\"></iframe>", "text/html", "utf-8");
}
I was trying to use this:
recyclerView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {
@Override
public void onChildViewAttachedToWindow(View view) {
visibleWebView.add(webView);
}
@Override
public void onChildViewDetachedFromWindow(View view) {
webView.onPause();
}
});
Please help me to solve this problem. Any help will be appreciated. Thanks!
Upvotes: 1
Views: 2380
Reputation: 664
for pause video in android studio web view you can use webview.onPause first set onscroll change listener for recycler view and pause web view when recycler view scrolled. But their will be a problem if you place image view over webview for thumbnail then you won't get play event. So it will be good and very useful if you will customize the webview events. that will be very helpful. Thank You fr the help. :-)
Upvotes: 1
Reputation: 984
I don't think there is any way to do that. I tried to do some research on that as well. But wasn't able to find anything even saying that there is a way to do that.
Upvotes: 0