Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play Vimeo Video in Android app

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.

like image 283
URAndroid Avatar asked Mar 14 '13 07:03

URAndroid


People also ask

How do I watch Vimeo on the app?

Mobile app: Download the Vimeo mobile app to your phone or tablet. Within the app, log in to Vimeo, then navigate to your Watch Later queue, where you'll find your purchased videos, ripe for the viewing.

Does Vimeo work on Android?

The Vimeo Android mobile app is compatible with phones and tablets running Android 7.0 (Nougat) and newer. We do our best to support most Android mobile devices, but due to the open nature of Android, we're unable to comprehensively test the app in all environments and markets.

Why can't I play a Vimeo video?

Browser cache that has not been cleared and browser that is old and outdated. If your browser is not updated and you have an older browser you could face problems watching Vimeo videos. 1. Vimeo needs browsers that can decode videos in a player that has HTML5 functionality.


2 Answers

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");
}
like image 172
ismail uzunok Avatar answered Nov 10 '22 16:11

ismail uzunok


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.

like image 30
Muhamed El-Banna Avatar answered Nov 10 '22 17:11

Muhamed El-Banna