在Android中播放Vimeo视频,包含iframe的视频网址 [英] Play Vimeo video in Android , video url containing iframe
本文介绍了在Android中播放Vimeo视频,包含iframe的视频网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我正在开发要播放vimeo视频的android应用程序,正在api中获取Api的响应,并使用webview播放视频,但播放效果很好,但是webview显示的内容非常小,正在播放的视频是我的问题也很小
Hello i am working on android application in which i want to play vimeo videos , i am getting response from Api in json and playing video using webview and it is playing good , but the webview is displaying very small and the playing video is also small my problems are
- 我希望播放视频的宽度与Android设备的宽度一致.我可以从Displaymetrics获取它,但如何设置为iframe?
- 我想为播放视频添加媒体控制器的自定义视图. 自定义控制器,例如播放暂停图标
- I want playing video width to be according to android device width. I can get it from Displaymetrics but how to set to iframe ?
- I want to inflate custom view of media controller for playing videos. Custom controller like play pause icon
我从api收到这种url响应
I am getting this kind of url response from api
<iframe src="https://player.vimeo.com/video/video_id" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
在video_id上,我正在获取视频ID
at video_id i am getting the video id
下面是我使用的代码
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.getSettings().setPluginState(WebSettings.PluginState.ON_DEMAND);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
String data_html=getexplore_list.get(pos).getVideo_url();
webView.loadDataWithBaseURL("http://vimeo.com", data_html, "text/html", "UTF-8", null);
请提供任何解决方案或链接将不胜感激
Please Provide any solution or link will be grateful
推荐答案
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和宽度.它正在工作.
change id and width. it is working.
这篇关于在Android中播放Vimeo视频,包含iframe的视频网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文