有没有办法在Android中的WebView
或VideoView
中播放Vimeo视频。任何玩Vimeo的源代码对我都有帮助。请帮忙。
答案 0 :(得分:4)
将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");
}
答案 1 :(得分:1)
如上所述here
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和宽度。它正在工作。