Android webview html5 video autoplay not working on android 4.0.3
[upgraded to answer per request]
Autoplay on most mobile platforms (Android, iOS) gets blocked to avoid poor user experiences - video should only play following a user action. You can usually work around it by triggering the play() on another event (eg the onloaded event)
Android webview video autoplay success, but same apk fails on android Tv mini pc?
I realize this is an old question but this answer might help someone down the road:
Android (and iOS both) disabled the autoplay
tag in HTML5 video
nodes in the Chrome or native browser. Playing a video requires user interaction (onClick or onMouseOver or something). However, one can autoplay videos in one's own WebView if necessary.
To autoplay videos in an Android Webview, post Android 4.4:
webview.setWebChromeClient(new WebChromeClient());
webview.getSettings().setMediaPlaybackRequiresUserGesture(false);
How to auto play iframe youtube on webview android
I think its not possible in webview or android browsers. To achieve auto playing, I think you need "YOUTUBE API".
Check below link :
1] There's no way method to do autoplay video on android platform?
2] Youtube Api android autostart
These above links will give you idea about auto playing as well as youtube api.
HTML5 Video: How to enable *non-muted* autoplay in Chrome for Android
If you want to do it for a device you control then you can (though obviously it's not something you can easily get users to do for their devices as it applies browser wide, not site specific).
Navigate to chrome://flags
and set gesture requirement for media playback
(about three or four pages down the list) to disabled
Autoplay video on mobile? Facebook Home does it. What am I missing?
Autoplay on most mobile platforms (Android, iOS) gets blocked to avoid
poor user experiences - video should only play following a user
action. You can usually work around it by triggering the play() on
another event (eg the onloaded event)
Facebook Home provides a video type extension .ogv
which worked on FireFox Beta only (I tried both Google chrome And Android default browser, but it just shows the poster image)
<video poster="Poster.jpg" autoplay="1" loop="1">
<source src="myVideo.mp4">
<source src="myVideo.ogv">
</video>
Demo
Another solution is to add event listener
to trigger the video to be played when the user clicks on the video element
<video id="myVideo" poster="Poster.jpg">
<source src="myVideo.mp4">
<source src="myVideo.ogv">
</video>
JS:
var video = document.getElementById('myVideo');
video.addEventListener('click',function(){
video.play();
},false);
Demo Works with Firefox beta (Inside windows) But for in Android Browser it calls Video Player App to play the video
Resources:
- Ogg - Wikipedia
- Android webview html5 video autoplay not working on android 4.0.3: Best answer
- Making HTML5 Video work on Android phones
Related Topics
Android Studio on a Hardware That Does Not Support Virtualization Technology
Intent Filter to Download Attachment from Gmail Apps on Android
Using Android Studio with Vuforia
Android: How to Return Async JSONobject from Method Using Volley
A Correct Way to Convert Byte[] in Java to Unsigned Char* in C++, and Vice Versa
Scaling a Phonegap App for Different Android Screen Sizes/Densities
Error Inflating Class Android.Support.V4.View.Viewpager
Equivalent of Listview.Setemptyview in Recyclerview
How to Listen for a Custom Uri
How to Add a Button at The End of Recyclerview
Startactivityforresult from Activitygroup
How to Detect If Device Support Notch Display
Widget Not Updated on Launcher Restart
Android Layout with Square Buttons
Eclipse Indexer Errors When Using Stl with Android Ndk
Input Elements on Android 4.X Can Not Be Styled When Focused