Disable html5 video autoplay

前端 未结 8 1332
感情败类
感情败类 2021-02-02 07:10

How can I disable html5 video autoplay?

what I\'ve tried:

相关标签:
8条回答
  • 2021-02-02 07:38

    I'd remove the autoplay attribute, since if the browser encounters it, it autoplays!

    autoplay is a HTML boolean attribute, but be aware that the values true and false are not allowed. To represent a false value, you must omit the attribute.

    The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.

    Also, the type goes inside the source, like this:

    <video width="640" height="480" controls preload="none">
       <source src="http://example.com/mytestfile.mp4" type="video/mp4">
       Your browser does not support the video tag.
    </video>
    

    References:

    • http://www.w3.org/TR/html-markup/video.html
    • HTML Spec (boolean attributes)
    0 讨论(0)
  • 2021-02-02 07:43

    remove the autoplay in video tag. use code like this

    <video class="embed-responsive-item"  controls>
       <source src="http://example.com/video.mp4">
       Your browser does not support the video tag.
    </video>

    it is 100% working

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