3

i am trying to load a webpage on a web view where the page has a video in it. i am able to load the web page on the web view but the video is not playing and the audio is heard. this is the link i m loading to a web view.

http://html5videoformatconverter.com/html5-video-tag-example.html

and all i m doing is

  public class VideoActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    WebView mWebView = (WebView) findViewById(R.id.wvVideo);
    mWebView.setWebChromeClient(chromeClient);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setPluginsEnabled(true);
    mWebView.loadUrl("http://html5videoformatconverter.com/html5-video-tag-example.html");

}
private WebChromeClient chromeClient = new WebChromeClient(){

    @Override
    public void onShowCustomView(View view, CustomViewCallback callback) {
        // TODO Auto-generated method stub
        super.onShowCustomView(view, callback); 
        if(view instanceof FrameLayout){
            FrameLayout frame  = (FrameLayout)view;
            if(frame.getFocusedChild()instanceof VideoView){
            VideoView video =  (VideoView)frame.getFocusedChild();
                frame.removeView(video);
                           video.start();

            }
        }

    }

};

}

pls help me modify my code. thanks

cavallo
  • 4,414
  • 9
  • 39
  • 61

5 Answers5

2

This worked for me, problem was to do with file permissions on the locally stored video. Hope it helps!

<video width="365" height="200" src="/mnt/SDcard/media/video/abc.mp4" controls autobuffer></video>
biegleux
  • 13,179
  • 11
  • 45
  • 52
droiding
  • 41
  • 1
2

Android Browser and WebView has many known problems playing HTML5 <video> videos.

Android webview cannot render youtube video embedded via iframe

Unless you can target Android 4.0 or good modern firmwars, the current workaround is to have a thumbnail image link to a video and then this link opens the video in the native Android video player.

For more information with HTML5 video problems on Android please feel free to search stackoverflow.com.

Community
  • 1
  • 1
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • This bit, please read: the current workaround is to have a thumbnail image link to a video file and then this link opens the video in the native Android video player. – Mikko Ohtamaa Apr 17 '12 at 15:11
  • cavallo kindly update the post with the solution rather than keeping quiet – Fred Ondieki May 15 '15 at 20:02
0

As @Mikko says, this is a tricky area.

One thing to check is that you have hardware acceleration enabled. I encounter the exact same symptoms the OP describes when leaving it turned off.

You can enable it at the application or at the activity level:

<application 
    android:icon="@drawable/icon_72" 
    android:logo="@drawable/icon_menu_72"
    android:label="@string/app_name"
    android:hardwareAccelerated="true"
    >

OR

<activity 
    android:name=".MyActivity"
    android:hardwareAccelerated="true"
    >
dokkaebi
  • 9,004
  • 3
  • 42
  • 60
0

When I encountered this problem it was due to the compression type. For android I had to use base profile compression rather than high profile compression. ffmpeg compatibility has a description.

I answered a similar question here.

Community
  • 1
  • 1
Leo
  • 1,495
  • 23
  • 41
0

I was converting my mobile website with youtube embeds into android app....this project helped me get rid of getting the video to fullscreen in webview. All my problems were solved. You can get something from here. https://code.google.com/p/html5webview/

Ananth
  • 1,798
  • 2
  • 11
  • 8