how to play html5 video on a webview android

前端 未结 5 2034
花落未央
花落未央 2021-01-06 14:56

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 he

相关标签:
5条回答
  • 2021-01-06 15:17

    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/

    0 讨论(0)
  • 2021-01-06 15:21

    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"
        >
    
    0 讨论(0)
  • 2021-01-06 15:30

    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>
    
    0 讨论(0)
  • 2021-01-06 15:34

    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.

    0 讨论(0)
  • 2021-01-06 15:37

    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.

    0 讨论(0)
提交回复
热议问题