Перевод не завершен. Пожалуйста, помогите перевести эту статью с английского.

Для встраивания видео контента в документ используйте элемент HTML <video>. Видео элемент может содержать один или несколько источников видео. Чтобы указать источник видео, необходимо использовать атрибут src или элемент <source>; браузер сам определит наиболее подходящий источник.

Для просмотра списка поддерживаемых форматов, перейдите по ссылке Поддерживаемые аудио и видео элементами форматы мультимедийных файлов.

Контекст Использования

  • Permitted contentIf the element has a src attribute: zero or more <track> element, followed by transparent content that contains no media elements, that is no <audio> or <video>
    Else: zero or more <source> element, followed by zero or more <track> element, followed by transparent content that contains no media elements, that is no <audio> or <video>.
Content categories Flow content, phrasing content, embedded content. If it has a controls attribute: interactive content and palpable content.
Tag omission None, both the starting and ending tag are mandatory.
Допустимые родительские элементы Any element that accepts embedded content.
DOM интерфейс HTMLVideoElement


Как и все HTML элементы, этот элемент поддерживает глобальные атрибуты.

Логический атрибут; если указан, то видео начнет воспроизводится автоматически, как только это будет возможно сделать без остановки, чтоб закончить загрузку данных.
A Boolean attribute; if specified, the video will automatically begin buffering even if it's not set to play automatically. Use this attribute only when it is very likely that the user will watch the video. The video is buffered until the media cache is full.
Implementation note: though part of the early drafts of the HTML5 specification, the autobuffer attribute has been removed in later releases. It has been removed from Gecko 2.0 and other browsers, and never implemented in some. The spec defines a new enumerated attribute, preload, to replace the autobuffer attribute, with a different syntax. ошибка 548523
An attribute you can read to determine the time ranges of the buffered media. This attribute contains a TimeRanges object.
Если этот атрибут присутствует, тогда браузер отобразит элементы управления, чтобы позволить пользователю управлять воспроизведением видео, регулировать громкость, осуществлять перемотку, а также ставить на паузу и возобновление воспроизведение.
This enumerated attribute indicates whether to use CORS to fetch the related image. CORS-enabled resources can be reused in the <canvas> element without being tainted. The allowed values are:
Sends a  cross-origin request without a credential. In other words, it sends the Origin: HTTP header without a cookie, X.509 certificate, or performing HTTP Basic authentication. If the server does not give credentials to the origin site (by not setting the Access-Control-Allow-Origin: HTTP header), the image will be tainted, and its usage restricted.
Sends a  cross-origin request with a credential. In other words, it sends the Origin: HTTP header with a cookie, a certificate, or performing HTTP Basic authentication. If the server does not give credentials to the origin site (through Access-Control-Allow-Credentials: HTTP header), the image will be tainted and its usage restricted.
When not present, the resource is fetched without a CORS request (i.e. without sending the Origin: HTTP header), preventing its non-tainted used in <canvas> elements. If invalid, it is handled as if the enumerated keyword anonymous was used. See CORS settings attributes for additional information.
Высота области отображения видео в пикселях.
Логический атрибут; если указан, то по окончанию проигрывания, видео автоматически начнет воспроизведение с начала.
Логический атрибут, который определяет значение по умолчания для аудио дорожки, содержащуюся в видео. Если атрибут указан, то аудио дорожка воспроизводиться не будет. Значение атрибута по умолчанию - "ложь", и это означает, что звук будет воспроизводиться, когда видео воспроизводится.
A TimeRanges object indicating all the ranges of the video that have been played.
This enumerated attribute is intended to provide a hint to the browser about what the author thinks will lead to the best user experience. It may have one of the following values:
  • none: indicates that the video should not be preloaded.
  • metadata: indicates that only video metadata (e.g. length) is fetched.
  • auto: indicates that the whole video file could be downloaded, even if the user is not expected to use it.
  • the empty string: synonym of the auto value.

If not set, its default value is browser-defined (i.e. each browser may have its default value). The spec advises it to be set to metadata.

Usage notes:
  • The autoplay attribute has precedence over preload. If autoplay is specified, the browser would obviously need to start downloading the video for playback.
  • The specification does not force the browser to follow the value of this attribute; it is a mere hint.
A URL indicating a poster frame to show until the user plays or seeks. If this attribute isn't specified, nothing is displayed until the first frame is available; then the first frame is shown as the poster frame.
The URL of the video to embed. This is optional; you may instead use the <source> element within the video block to specify the video to embed.
Ширина области отображения видео в пикселях.


The <video> element can fire many different events.


<!-- Simple video example -->
<video src="videofile.ogg" autoplay poster="posterimage.jpg">
  Sorry, your browser doesn't support embedded videos, 
  but don't worry, you can <a href="videofile.ogg">download it</a>
  and watch it with your favorite video player!

<!-- Video with subtitles -->
<video src="foo.ogg">
  <track kind="subtitles" src="foo.en.vtt" srclang="en" label="English">
  <track kind="subtitles" src="foo.sv.vtt" srclang="sv" label="Svenska">

The first example plays a video, starting playback as soon as enough of the video has been received to allow playback without pausing to download more. Until the video starts playing, the image "posterimage.jpg" is displayed in its place.

The second example allows the user to choose between different subtitles.

Multiple Sources Example

<video width="480" controls poster="https://archive.org/download/WebmVp8Vorbis/webmvp8.gif" >
  <source src="https://archive.org/download/WebmVp8Vorbis/webmvp8_512kb.mp4" type="video/mp4">
  <source src="https://archive.org/download/WebmVp8Vorbis/webmvp8.ogv" type="video/ogg">
  <source src="https://archive.org/download/WebmVp8Vorbis/webmvp8.webm" type="video/webm">
  Your browser doesn't support HTML5 video tag.

You can try the preceding example on HTML5 video demo example with live preview code editor.

Server support

If the MIME type for the video is not set correctly on the server, the video may not show or show a gray box containing an X (if JavaScript is enabled).

If you use Apache Web Server to serve Ogg Theora videos, you can fix this problem by adding the video file type extensions to "video/ogg" MIME type.  The most common video file type extensions are ".ogm", ".ogv", or ".ogg"To do this, edit the "mime.types" file in "/etc/apache" or use the "AddType" configuration directive in httpd.conf.

AddType video/ogg .ogm
AddType video/ogg .ogv
AddType video/ogg .ogg

If you serve your videos as WebM, you can fix this problem for the Apache Web Server by adding the extension used by your video files (".webm" is the most common one) to the MIME type "video/webm" via the "mime.types" file in "/etc/apache" or via the "AddType" configuration directive in httpd.conf.

AddType video/webm .webm

Your web host may provide an easy interface to MIME type configuration changes for new technologies until a global update naturally occurs.

Интерфейс DOM

Этот элемент реализует интерфейс HTMLVideoElement.

Совместимость браузера

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 3.0 3.5 (1.9.1) 9.0 10.5 3.1
autoplay attribute 3.0 3.5 (1.9.1) 9.0 10.5 3.1
buffered attribute ? 4.0 (2.0) ? (Да) ?
controls attribute 3.0 3.5 (1.9.1) 9.0 10.5 3.1
crossorigin attribue ? 12.0 (12.0) ? ? ?
loop attribute 3.0 11.0 (11.0) 9.0 10.5 3.1
muted attribute 30.0 11.0 (11.0) 10.0 (Да) 5.0
played property ? 15.0 (15.0) ? (Да) ?
poster attribute 3.0 3.6 (1.9.2) 9.0 10.5 3.1
preload attribute 3.0 4.0 (2.0) 9.0 (Да) 3.1
src attribute 3.0 3.5 (1.9.1) 9.0 10.5 3.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 1.0 (1.0) ? ? ?
autoplay attribute ? 1.0 (1.0) 8.1 ? (Да)[1]
buffered attribute ? 4.0 (2.0) ? ? ?
controls attribute ? 1.0 (1.0) ? ? ?
loop attribute ? 11.0 (11.0) 8.0 ? 6.0
muted attribute ? 11.0 (11.0) 8.0 ? ?
played property ? 15.0 (15.0) ? ? ?
poster attribute ? 1.0 (1.0) ? ? ?
preload attribute ? 4.0 (2.0) ? ? ?
src attribute ? 1.0 (1.0) ? ? ?
crossorigin attribute ? 12.0 (12.0) ? ? ?

[1] This feature is only available on iOS 6.0.

Смотрите также

Метки документа и участники

 Внесли вклад в эту страницу: fill.anton
 Обновлялась последний раз: fill.anton,