📜  HTML video标签

📅  最后修改于: 2020-11-04 00:54:51             🧑  作者: Mango

HTML视频标签

HTML 5支持

当前,HTML视频标签支持三种视频格式:

  • mp4
  • webM
  • ogg

让我们看一下定义了哪个Web浏览器支持视频文件格式的表。

Browser mp4 webM ogg
ie browser Internet Explorer yes no no
chrome browser Google Chrome yes yes yes
firefox browser Mozilla Firefox yes yes yes
opera browser Opera no yes yes
safari browser Apple Safari yes no no

Android还支持mp4格式。

HTML视频标签示例

让我们看看使用HTML video标签播放mp4文件的代码。


让我们看一下使用HTML视频标签播放ogg文件的示例。


支持的浏览器

Element chrome browser Chrome ie browser IE firefox browser Firefox opera browser Opera safari browser Safari
Yes Yes Yes Yes Yes

HTML视频标记的属性

让我们看一下HTML 5视频标记属性的列表。

Attribute Description
controls It defines the video controls which is displayed with play/pause buttons.
height It is used to set the height of the video player.
width It is used to set the width of the video player.
poster It specifies the image which is displayed on the screen when the video is not played.
autoplay It specifies that the video will start playing as soon as it is ready.
loop It specifies that the video file will start over again, every time when it is completed.
muted It is used to mute the video output.
preload It specifies the author view to upload video file when the page loads.
src It specifies the source URL of the video file.

HTML视频标签属性示例

让我们看一下使用高度,宽度,自动播放,控件和循环属性的HTML视频标记示例。


HTML视频格式的MIME类型

可用的MIME类型HTML视频标签如下所示。

Video Format MIME Type
mp4 video/mp4
ogg video/ogg
webM video/webM