One problem encountered this time was that webview could not play the video, and Google found that it could be set up
Setting. setpluginsenabled (true );
This allows you to play the video, but the latest official SDK says this method has to be abandoned. We recommend that you use this method.
Setting. setpluginstate (pluginstate. On );
Currently, both methods can be used. However, when the webview page is complete, you can still hear the video playing sound. so you can check the webview
The onresume method can be used to Resume playback,
Onpause can pause playback,
However, both methods are in the added in API
Level 11 is added, so reflection is required.
Stop playback: Use the following in the onpause method of the page:
Webview. getclass (). getmethod ("onpause"). Invoke (webview, (object []) null );
Resume playback: Use the following in the onresume method of the page:
Webview. getclass (). getmethod ("onresume"). Invoke (webview, (object []) null );
In this way, you can control the pause and resume of the video.
Another point:
Webview. resumetimers ()
Webview. pausetimers ();
There is a delay between the two methods, and after loading webview for the second time, the last video will be played again, but only the sound can be heard, so I personally feel unreliable, the browser of the system probably uses this method. After closing the browser based on the return part, you can still hear the sound.
If the content cannot be centered in the browser, you only need to set the following two familiarity:
Setting. setloadwithoverviewmode (true );
Setting. setusewideviewport (true );
Continue study:
The same Code, tested on the android + device, found that the video still cannot be played, so the following solution is added:
1. Add:
Android: hardwareaccelerated = "true"
2. This code must be added. I don't fully understand why, but I can play it with this code.
Webview. setwebchromeclient (New webchromeclient ());
These two steps can be played. Some people say that the Android: hardwareaccelerated = "true" should be added in the application configuration. At the beginning, I also added it, however, I later found that the flash can be played with this feature.
But now the trouble is that the video cannot be played in full screen mode. After you click the full screen button and click the play and pause button again, the video will not respond and cannot be played again.
The following solutions are available on the Internet:
Http://www.techfreestyle.com/fixed-android-4-0-full-screen-flash-problem-in-webview this method has been tested and cannot solve the problem.
Https://github.com/android/platform_packages_apps_browser/blob/master/src/com/android/browser/BaseUi.java this looks like source code, because the code is too much, so there is no research.
When Daniel passes by, let's talk about how you solve the problem of full screen, thanks.