Resolve the video label cannot play the problem automatically under Android WebView _android

Source: Internet
Author: User
Under the WebView of Android

HTML5 's video settings AutoPlay properties

Or use the Play method in document ready

Can't make it play automatically

This problem can only be resolved using the WebView onpagefinished method, as follows:
Copy Code code as follows:

Mplayer.setwebviewclient (New Webviewclient () {
AutoPlay when finished loading via JavaScript injection
public void onpagefinished (webview view, String URL) {Mplayer.loadurl ("javascript: (function () {var videos = Document.get Elementsbytagname (' video '); for (Var i=0;i<videos.length;i++) {Videos[i].play ();}}) ()"); }
});

Putting the above code in the//here area solves the problem.
Copy Code code as follows:

public class Playeractivity extends activity {
protected void OnCreate (Bundle savedinstancestate) {
Here
}
}
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.