WebView Play H5 video problem black screen only sound no picture

Source: Internet
Author: User

How does Android use WebView to play Network video control play button?

Add in Code
Webview.getsettings (). Setjavascriptenabled (true);//Support JS
Webview.getsettings (). Setpluginsenabled (true);//Set WebView support plugin

Also add android:hardwareaccelerated= "true" hardware acceleration in the application of the manifest configuration file to play the video

How to Play network video in Android WebView

1. Create a new HTML file and edit its contents:

2. WebView set the WebView component to support JavaScript script to load the HTML for true,load.
3, There are many devices developed only sound, no picture, this time in the Androidmanifest.xml Add application application Set hardware rendering to true, in the OnCreate function to enable hardware rendering. That's a little vague.

1. androidmanifest.xml file Set the following properties:
Android:hardwareaccelerated= "true"

2, add in OnCreate:
GetWindow (). Addflags (
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

Do web video only sound no picture, generally this can be solved. Not all models can, there are exceptions, less.

WebView hardware acceleration causes page rendering Flicker
More than 4.0 of the system when we turn on hardware acceleration, WebView renders the page faster, and the drag is smoother. However, a side effect is that when the WebView view is obscured by a block, and then suddenly recovers (for example, by using Slidemenu to slide the webview from the side), the transition period is white and the interface flashes. The solution to this problem is to temporarily close the hardware acceleration of the webview before the transition period, and then open it after the transition period, with the following code:
if (Build.VERSION.SDK_INT >= build.version_codes. Honeycomb) {
Webview.setlayertype (view.layer_type_software, NULL);
}


WebView Play H5 video problem black screen only sound no picture

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.