how to play html5 video on a webview android

隐身守侯 提交于 2019-12-01 00:18:05
Mikko Ohtamaa

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.

droiding

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>

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"
    >
Leo

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.

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/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!