How to autoplay HTML5 mp4 video on Android?

后端 未结 15 951
一向
一向 2020-11-27 05:53

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 mp

相关标签:
15条回答
  • 2020-11-27 05:59

    Chrome has disabled it. https://bugs.chromium.org/p/chromium/issues/detail?id=159336 Even the jQuery play() is blocked. They want user to initiate it so bandwidth can be saved.

    0 讨论(0)
  • 2020-11-27 06:03

    Important Note: Be aware that if Google Chrome Data Saver is enabled in Chrome's settings, then Autoplay will be disabled.

    0 讨论(0)
  • 2020-11-27 06:04

    I don't think autoplay works on Android, but getting a video to play can be annoyingly tricky. I suggest giving this article a read: Making HTML5 Video work on Android phones.

    0 讨论(0)
  • 2020-11-27 06:07

    In Android 4.1 and 4.2, I use the following code.

        evt.initMouseEvent( "click", true,true,window,0,0,0,0,0,false,false,false,false,0, true );
        var v = document.getElementById("video");
        v.dispatchEvent(evt);
    

    where html is

        <video id="video" src="sample.mp4" poster="image.jpg" controls></video>
    

    This works well. But In Android 4.4, it does not work.

    0 讨论(0)
  • 2020-11-27 06:09

    Here is a plugin for PhoneGap which solved the problem for me: https://build.phonegap.com/plugins/1031

    I simply included it in my config.xml

    0 讨论(0)
  • 2020-11-27 06:13

    You can add the 'muted' and 'autoplay' attributes together to enable autoplay for android devices.

    e.g.

    <video id="video" class="video" autoplay muted >

    0 讨论(0)
提交回复
热议问题