如何在 webview 中使用 iframe 播放 vimeo 视频? [英] how to play vimeo video using iframe in webview?

查看:24
本文介绍了如何在 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");
    }
}

从谷歌研究后,我写了上面的代码,但没有工作.在这没有发生错误,但是当我点击播放按钮时,进度条会显示一段时间,然后它消失并再次显示播放按钮......有人可以建议我如何解决这个问题吗?

After researching from google I have written the above code but is not working. In this no errors are occurred but when I click on the play button progress bar is displaying for sometime and then it disappears and displays play button again... Could anyone please suggest me how to solve this problem?

推荐答案

这样做:

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

这篇关于如何在 webview 中使用 iframe 播放 vimeo 视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆