Skip to content Skip to sidebar Skip to footer

How To Play Vimeo Video Using Iframe In Webview?

public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVi

Solution 1:

You have to enable the hardware accelaration feature in andorid manifest. To work vimeo video on all devices, bec vimeo video is html5 type of video.

And here is link of vimeo video play which is working perfectly.

Solution 2:

constTheVideo = (props) => {
 const getVimeoUrl = (uri: string): string => {
        const value = uri.split("/");
        return value[value.length - 1];
    };
    enter code here

return (<><iframesrc={props.specificVideo?.url
                                ?.split("/")[2]
                                .startsWith("vimeo")
                                ? `https://player.vimeo.com/video/${getVimeoUrl(
                                      props.specificVideo?.url
                                  )}`
                                :props.specificVideo?.url ?? ""
                        }
                        width="{video_width}"height="{video_height}"frameBorder="0"title={props.specificVideo?.title ?? ""}
                        className="specvideoview-frame"
                    ></iframe></>)
}

Solution 3:

webView = (WebView)findViewById(R.id.presentation_webview);

        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setPluginsEnabled(true);
        webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); 

        DisplayMetrics displaymetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        int height = displaymetrics.heightPixels;
        int wwidth = displaymetrics.widthPixels;

        Log.e("h & w",wwidth+"-"+height);

        String data_html = "<!DOCTYPE HTML><htmlxmlns=\"http://www.w3.org/1999/xhtml\" xmlns:og=\"http://opengraphprotocol.org/schema/\" xmlns:fb=\"http://www.facebook.com/2008/fbml\"><head></head><bodystyle=\"margin:0000; padding:0000;\"><iframewidth='"+wwidth+"'height='"+height+"'src=\"http://player.vimeo.com/video/"+VIDEO_ID+"\" frameborder=\"0\"></iframe></body></html> ";

        webView.setWebViewClient(new MyWebViewClient());

        webView.loadDataWithBaseURL("http://vimeo.com", data_html, "text/html", "UTF-8", null); 

Try the above code and use device width and height to play the video.

Post a Comment for "How To Play Vimeo Video Using Iframe In Webview?"