Android uses WebView support to play Youku videos, potato videos

Source: Internet
Author: User

read a lot of articles and the so-called solution Android WebView play Youku, potatoes and other video methods, are what setpluginsenabled, after Android 4.x are not good, there is no such function, because Android 4.x have gone beyond the support of Flash. I've been messing with this thing for a half day, now the site is collecting and copying, wasting time. Only self-fencing, the following gives my solution, 1. Modify the Androidmanifest.xml to increase on the application node? 1android:hardwareaccelerated= "True" of course you can also add this property on the activity node where the WebView is located 2. Add android:layertype= "Hardware" to the layout xml of WebView? 123456<WebViewAndroid:id= "@+id/newscontent"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:layertype= "Hardware"# Be sure to choose hardware and use hardware here. >3. Set the appropriate properties in Java code? 12345678910WebSettings ws=newscontent.getsettings (); ws.setjavascriptenabled (true); Ws.setallowfileaccess (True); ws.setdatabaseenabled (true); ws.setdomstorageenabled (true); Ws.setsaveformdata (False ); ws.setappcacheenabled (true); Ws.setcachemode (Websettings.load_default); Ws.setloadwithoverviewmode (false);// <= = = must be set to False, or there's a sound, no image ws.setusewideviewport (true); 4. The next step is to solve the problem of video playback not stopping? 1234567891011121314151617181920@overrideprotected   void Onresume () {super.onresume (); Resume playback webview.resumetimers ();}   @Overrideprotected void OnPause () {super.onpause (); Pauses playback of webview.pausetimers ();}   @Overrideprotected void OnDestroy () {Super.ondestroy (); Be sure to destroy, otherwise you cannot stop playing Webview.destroy ();} OK, that's it, Android 4.x playback is no problem .... And so forget, if WebView open a webpage that contains a link to share, the link that needs to be shared is a generic link that is, <iframe src= "HTTP://PLAY.YOUKU.COM/XJLKDFJAKLFJDSA"  />, if the direct use of embed will not play, or for that reason, Android does not support Flash plugin playback,

Android uses WebView support to play Youku videos, potato videos

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.