I had developed a mobile page by asp.net to play mp4 video.
I know iOS had disabled the autoplay function to minimize user bandwidth, so how can i autoplay HTML5 mp4 video on Android ?
I had already put autoplay in HTML5 code, but it doesn't work.
The following is my code:
<video autoplay controls id='video1' width='100%' poster='images/top_icon.png' webkitEnterFullscreen poster preload='true'> <source src='http://192.xxx.xxx.xx/XXXXVM01.mp4' type='video/mp4; codecs='avc1.42E01E, mp4a.40.2' > </video>
Moreover, I had fixed the problem that user click on the image overlay can play the video. Thanks Karthi
here are the code:
<script type="text/javascript"> $(document).ready(function() { $("#video1").bind("click", function() { var vid = $(this).get(0); if (vid.paused) { vid.play(); } else { vid.pause(); } }); }); </script>
Thanks
Joe
Tap “Settings” to configure the in-app settings. Tap on the second option in the list, the one labelled “Autoplay”. Tap “Autoplay”, it will be the second item in the settings list. To toggle autoplay on or off, simply tap the slider so the setting is disabled or enabled as preferred.
Mobile device settings can block autoplay Most mobile devices, including Apple iPhones, Apple iPads and many Android and Microsoft devices do not support the video autoplay feature so your video will not play automatically if a visitor is on one of these devices.
Muted autoplay is always allowed. Autoplay with sound is allowed if: User has interacted with the domain (click, tap, etc.). On desktop, the user's Media Engagement Index threshold has been crossed, meaning the user has previously played video with sound.
The autoplay attribute is a boolean attribute. When present, the video will automatically start playing. Note: Chromium browsers do not allow autoplay in most cases.
You can add the 'muted' and 'autoplay' attributes together to enable autoplay for android devices.
e.g.
<video id="video" class="video" autoplay muted >
I used the following code:
// get the video var video = document.querySelector('video'); // use the whole window and a *named function* window.addEventListener('touchstart', function videoStart() { video.play(); console.log('first touch'); // remove from the window and call the function we are removing this.removeEventListener('touchstart', videoStart); });
There doesn't seem to be a way to auto-start anymore.
This makes it so that the first time they touch the screen the video will play. It will also remove itself on first run so that you can avoid multiple listeners adding up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With