how to play vimeo video using iframe in webview?

巧了我就是萌 提交于 2019-11-28 09:15:06

Do this:

<iframe src="//player.vimeo.com/video/VIDEO_ID" 
        width="515" 
        height="340" 
        frameborder="0" 
        webkitallowfullscreen mozallowfullscreen allowfullscreen>
</iframe>
ag.pronto

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.

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> <html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:og=\"http://opengraphprotocol.org/schema/\" xmlns:fb=\"http://www.facebook.com/2008/fbml\"> <head></head> <body style=\"margin:0 0 0 0; padding:0 0 0 0;\"> <iframe width='"+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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!