Today found WebView play Youku video click on the play button did not respond, so look at official documents and search solutions, the following is what I do on the basis of other people to add:Android WebView can't play video, can't pause, continue playing video problem, can't center content problem based on browserTurn from: http://blog.csdn.net/it_ladeng/article/details/8136534 This encounter a problem is webview can't play video, checked the next Google found can set
Setting.setpluginsenabled (TRUE); (from API 11 support, can not add)
This to play video, but the latest official SDK said this method to give up, recommended to use
Setting.setpluginstate (Pluginstate.on); (from API 11 support, can not add)
At present, these two methods can be, but WebView's pages are actually still able to hear the video playback of the sound, so there is a search for the next found WebView
The Onresume method can continue to play,
OnPause can pause playback,
However, both of these methods are added in the added in API level 11, so it needs to be done with reflection.
Stop playback: Used in the OnPause method of the page:
Webview.getclass (). GetMethod ("OnPause"). Invoke (WebView, (object[]) null); (Low version test OK)
Continue playback: Used in the Onresume method of the page:
Webview.getclass (). GetMethod ("Onresume"). Invoke (WebView, (object[]) null); (Low version test OK)
This allows you to control the pause and resume playback of the video.
In addition, say one thing:
Webview.resumetimers () (not reliable)
Webview.pausetimers (); (not reliable)
These two methods have a delay, and the second reload WebView will appear after the last playback of the video will continue to play, but only hear the sound, so the personal feeling is not reliable, the system's browser is estimated to use this method, the return of the browser can also hear the sound after closing.
Unable to center the content according to the browser the problem is as long as you set the following two familiar:
Setting.setloadwithoverviewmode (TRUE);
Setting.setusewideviewport (TRUE);
Continue to study:
The same code, after testing on a android4.0+ device, or not playing the video, continues to add the following workaround:
1. In WebView's activity configuration, add:
Android:hardwareaccelerated= "true"
(The official document explains that:
Hardware acceleration is enabled by the default if your Target API level is >=14
Http://developer.android.com/guide/topics/graphics/hardware-accel.html
So only need to modify the next manifest file, do not need to set this property is also possible)
2. You have to add this code, do not understand why, but add this will be able to play
Webview.setwebchromeclient (New Webchromeclient ()); (Must be added)
These two steps can be played, some people say in the application configuration also add: Android:hardwareaccelerated= "true", the beginning of the time I also added, but later found to remove this also can play flash
But now the trouble is that the video can not play full-screen, as long as the full screen button clicked, once again click the Play and Pause button, the video will not have any reaction, can not continue to play.
Online search for the relevant solutions:
Http://www.techfreestyle.com/fixed-android-4-0-full-screen-flash-problem-in-webview This method has been tested and does not solve the problem.
Https://github.com/android/platform_packages_apps_browser/blob/master/src/com/android/browser/BaseUi.java This seems to be the source code, because of many codes, so has not been studied.
"Go" Android WebView play Video Summary