Under Android webview
html5's video sets autoplay attribute
Or use the play method in document ready
None of them can be automatically played
You can only use the onPageFinished method of webview to solve this problem, the code is as follows:
(new WebViewClient() {
// autoplay when finished loading via javascript injection
public void onPageFinished(WebView view, String url) { ("javascript:(function() { var videos = ('video'); for(var i=0;i<;i++){videos[i].play();}})()"); }
});
Putting the above code in //here can solve the problem.
public class PlayerActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
//here
}
}
html5's video sets autoplay attribute
Or use the play method in document ready
None of them can be automatically played
You can only use the onPageFinished method of webview to solve this problem, the code is as follows:
Copy the codeThe code is as follows:
(new WebViewClient() {
// autoplay when finished loading via javascript injection
public void onPageFinished(WebView view, String url) { ("javascript:(function() { var videos = ('video'); for(var i=0;i<;i++){videos[i].play();}})()"); }
});
Putting the above code in //here can solve the problem.
Copy the codeThe code is as follows:
public class PlayerActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
//here
}
}