6

有什么方法可以在 Android 中WebViewVideoView在 Android 中播放 Vimeo Video。任何播放 Vimeo 的源代码都会对我有所帮助。请帮忙。

4

2 回答 2

4

将 WebView 添加到您的布局

<WebView
    android:id="@+id/webView1"
    android:layout_width="400dp"
    android:layout_height="400dp" />

然后加

@Override
protected void onCreate(Bundle savedInstanceState)
{
   webView1.loadData("<iframe src=\"http://player.vimeo.com/video/"+VIDEO_ID+"\" width=\"180px\" height=\"180px\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>", "text/html", "utf-8");
}
于 2014-11-28T19:32:11.170 回答
1

正如这里提到的

mViewHolder.webView.getSettings().setJavaScriptEnabled(true);

String yourData = "<div id='made-in-ny'></div>\n" +
            "\n" +
            "<script src='https://player.vimeo.com/api/player.js'></script>\n" +
            "<script>\n" +
            "    var options = {\n" +
            "        id: 59777392,\n" +
            "        width: 540,\n" +
            "        loop: true\n" +
            "    };\n" +
            "\n" +
            "    var player = new Vimeo.Player('made-in-ny', options);\n" +
            "\n" +
            "    player.setVolume(0);\n" +
            "\n" +
            "    player.on('play', function() {\n" +
            "        console.log('played the video!');\n" +
            "    });\n" +
            "</script>";

mViewHolder.webView.loadData(yourData, "text/html; charset=utf-8", "UTF-8");

更改 id 和宽度。这是工作。

于 2020-06-09T09:59:06.943 回答