禁用html5视频自动播放 [英] Disable html5 video autoplay

查看:1680
本文介绍了禁用html5视频自动播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何禁用html5视频自动播放?

How can I disable html5 video autoplay?

我尝试过的事情:

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

推荐答案

我将删除autoplay属性,因为如果浏览器遇到该属性,它将自动播放!

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

autoplay HTML布尔属性,但请注意,不允许使用值truefalse.要表示false值,必须忽略该属性.

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.

值"true"表示和假"不允许在布尔属性上使用.要表示一个假值,必须完全省略该属性.

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)

这篇关于禁用html5视频自动播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆