1

I am developing a android application in which, i have to play a vimeo video. Video is given in the form of an URL. I want to load it in a webview. I tried it, but the video is not playing. I got a still picture of video, but it is not playing,

videoPlayer = (WebView) findViewById(R.id.videoPlayer);   

    WebSettings webViewSettings = videoPlayer.getSettings();
    webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webViewSettings.setJavaScriptEnabled(true);
    webViewSettings.setPluginsEnabled(true);
    webViewSettings.setBuiltInZoomControls(true);
    webViewSettings.setPluginState(PluginState.ON); 
    videoPlayer.loadData("<iframe src=\</**HERE COMES VIDEO LINK*/>width=\"1280\" 
                           height=\"720\" frameborder=\"0\" 
                           webkitAllowFullScreen mozallowfullscreen 
                           allowFullScreen></iframe>", "text/html", "utf-8");

can anyone tell me where i gone wrong? or Vimeo video cannot be played on Android. Is there any vimeo player plugin or anything like flash player for Android or can anyone suggest me any other solution for this problem?

sschrass
  • 7,014
  • 6
  • 43
  • 62
Sanal V
  • 281
  • 1
  • 5
  • 17

2 Answers2

1

Try doing something like this for a youtube normal video link..it works for me :

        String videoPoP = "http://www.youtube.com/v/A6kCkkLo6Rw?";
        webview.getSettings().setJavaScriptEnabled(true);
        String widthAndHeight = "width=\"" + widthdp + "\" height=\"" + heightdp + "\"";            

        String temp = "<object "
                + widthAndHeight
                + ">"
                + "<body style='margin:0;padding:0;'>"
                + "<param name='allowFullScreen' value='false'>"
                + "</param><param name='allowscriptaccess' value='always'>"
                + "</param><embed src='"
                + videoPoP
                + "'"
                + " type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true'"
                + widthAndHeight + "></embed></object>";

        webview.loadData(temp, "text/html", "utf-8");

The following code should work for a vimeo video as well. so try and see

Android2390
  • 1,150
  • 12
  • 21
0

I'm stuck with the same problem. As mentioned in the documentation:

In order to support inline HTML5 video in your application, you need to have hardware acceleration turned on, and set a WebChromeClient.

More Infos here: http://developer.android.com/reference/android/webkit/WebView.html

However, it's not working on all devices, especially those with Froyo. I'm still trying to find a workaround (at least for Dailymotion and Vimeo videos)

Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77
parser_failed
  • 697
  • 9
  • 20
  • Yes, but things get complicated when you try to go fullscreen. I had to refactor the code from the froyo web browser application to make it work. – parser_failed Apr 12 '13 at 23:13
  • http://stackoverflow.com/questions/15895437/how-to-play-vimeo-video-using-iframe-in-webview see this link @parser_failed – Venkat Apr 15 '13 at 04:10