Is there any way to play Vimeo Video in WebView
or VideoView
in Android. Any source code for playing Vimeo will be helpful for me. Please help.
Asked
Active
Viewed 9,681 times
6

Sandeep Yohans
- 929
- 1
- 14
- 36

URAndroid
- 6,177
- 6
- 30
- 40
-
1Here is issue link https://vimeo.com/forums/help/topic:101891 This solution isn't stable but maybe you can use: https://github.com/droid28/VimeoVideo – Göksel Güren May 07 '13 at 10:07
-
https://stackoverflow.com/a/54252590/5065348 – AnsonChen Feb 05 '19 at 18:51
2 Answers
4
Add WebView to your layout
<WebView
android:id="@+id/webView1"
android:layout_width="400dp"
android:layout_height="400dp" />
Then add
@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");
}

ismail uzunok
- 163
- 1
- 1
- 14
-
1Instead of using width and height as static values, I believe is better to use `width=\"100%\" height=\"95%\"` – Carlo Espino Jul 28 '15 at 23:51
-
But this shows the URL of the video if any error occurs. How to handle that? – Bhaskar Jyoti Dutta Aug 15 '20 at 16:12
1
As mentioned 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");
change id and width. it is working.

Muhamed El-Banna
- 593
- 7
- 21