android – 如何在webview中使用iframe播放vimeo视频?

前端之家收集整理的这篇文章主要介绍了android – 如何在webview中使用iframe播放vimeo视频?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView wv=(WebView)findViewById(R.id.webView1);

        wv.getSettings().setJavaScriptEnabled(true);
        wv.getSettings().setAppCacheEnabled(true);
        wv.getSettings().setDomStorageEnabled(true);

        // how plugin is enabled change in API 8
        if (Build.VERSION.SDK_INT < 8) {
          wv.getSettings().setPluginsEnabled(true);
        } else {
          wv.getSettings().setPluginState(PluginState.ON);
        }
        String venkat="<iframe src=\"http://player.vimeo.com/video/27244727?portrait=0&color=333\" width=\"WIDTH\" height=\"HEIGHT\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>";
        wv.loadData(venkat,"text/html","UTF-8");
    }
}
@H_403_4@在谷歌研究之后,我写了上面的代码,但没有工作.在这个没有错误发生,但是当我点击播放按钮进度条显示一段时间,然后它消失并再次显示播放按钮…有人可以建议我如何解决这个问题?

解决方法

做这个:
<iframe src="//player.vimeo.com/video/VIDEO_ID" 
        width="515" 
        height="340" 
        frameborder="0" 
        webkitallowfullscreen mozallowfullscreen allowfullscreen>
</iframe>
原文链接:https://www.f2er.com/android/312317.html

猜你在找的Android相关文章