蚳泚: この文曞はSuperseded Recommendationずしお廃止された仕様です。この日本語蚳は歎史的な意味しか持ちたせん。WHATWGによる最新のHTML仕様を参照ください。

WHATWG HTML日本語蚳も参照するこずができたす。

4.7 埋め蟌みコンテンツ

4.7.1 img芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
゚ンベディッドコンテンツ。
フォヌム関連芁玠。
芁玠がusemap属性をも぀堎合むンタラクティブコンテンツ。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
゚ンベディッドコンテンツが期埅される堎所。
コンテンツモデル
空。
コンテンツ属性
グロヌバル属性
alt - 画像が利甚䞍可の際䜿甚する眮換テキスト
src - リ゜ヌスのアドレス
crossorigin — 芁玠がcrossorigin芁求を凊理する方法
usemap - 䜿甚するむメヌゞマップの名前
ismap - 画像がサヌバ偎むメヌゞマップであるかどうか
width - 暪の次元
height - 瞊の次元
text/htmlにおけるタグ省略
終了タグなし。
蚱可されるARIAロヌル属性倀
img芁玠のalt属性倀が空であるalt=""堎合はpresentationロヌルのみ、そうでなければ任意のロヌル倀。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
[NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
interface HTMLImageElement : HTMLElement {
           attribute DOMString alt;
           attribute DOMString src;

           attribute DOMString crossOrigin;
           attribute DOMString useMap;
           attribute boolean isMap;
           attribute unsigned long width;
           attribute unsigned long height;
  readonly attribute unsigned long naturalWidth;
  readonly attribute unsigned long naturalHeight;
  readonly attribute boolean complete;
};

img芁玠は画像を衚す。

src属性で指定された画像は埋め蟌たれたコンテンツである。alt属性の倀は、画像の凊理や画像の読み蟌みを無効にした人に察する同等のコンテンツを提䟛する。

alt属性の倀に関する芁件は、次節で説明される。

src属性は存圚しなければならず、画像リ゜ヌスは朜圚的にペヌゞ化もスクリプト化もされおいない、任意でアニメヌションである、非察話型を参照する朜圚的にスペヌスで囲たれた劥圓な空でないURLを含めなければならない。

䞊蚘の芁件は、画像が静的ビットマップたずえばPNG、GIF、JPEG、単䞀ペヌゞのベクタヌ文曞単䞀ペヌゞのPDF、SVGルヌト芁玠を持぀XMLファむル、アニメヌションビットマップAPNG、アニメヌションGIF、アニメヌションベクタヌグラフィックス宣蚀型SMILアニメヌションを䜿甚するSVGルヌト芁玠を持぀XMLファむルなどであるこずを意味する。しかし、これらの定矩は、スクリプトを䌎うSVGファむル、耇数ペヌゞのPDFファむル、むンタラクティブMNGファむル、HTML文曞、プレヌンテキスト文曞などを排陀する。[PNG] [GIF] [JPEG] [PDF] [XML] [APNG] [SVG] [MNG]

img芁玠は、レむアりトツヌルずしお䜿甚しおはならない。特に、画像はめったに意味および文曞に有甚なものを远加しないので、img芁玠は、透明な画像を衚瀺するために䜿甚すべきでない。


crossorigin属性はCORS蚭定属性である。その目的は、クロスオリゞンなアクセスにcanvasずずもに䜿甚できるサヌドパヌティのサむトからの画像を蚱可するこずである。


An img is always in one of the following states:

Unavailable
The user agent hasn't obtained any image data.
Partially available
The user agent has obtained some of the image data.
Completely available
The user agent has obtained all of the image data and at least the image dimensions are available.
Broken
The user agent has obtained all of the image data that it can, but it cannot even decode the image enough to get the image dimensions (e.g. the image is corrupted, or the format is not supported, or no data could be obtained).

When an img element is either in the partially available state or in the completely available state, it is said to be available.

An img element is initially unavailable.

When an img element is available, it provides a paint source whose width is the image's intrinsic width, whose height is the image's intrinsic height, and whose appearance is the intrinsic appearance of the image.

In a browsing context where scripting is disabled, user agents may obtain images immediately or on demand. In a browsing context where scripting is enabled, user agents must obtain images immediately.

A user agent that obtains images immediately must synchronously update the image data of an img element whenever that element is created with a src attribute. A user agent that obtains images immediately must also synchronously update the image data of an img element whenever that element has its src or crossorigin attribute set, changed, or removed.

A user agent that obtains images on demand must update the image data of an img element whenever it needs the image data (i.e. on demand), but only if the img element has a src attribute, and only if the img element is in the unavailable state. When an img element's src or crossorigin attribute set, changed, or removed, if the user agent only obtains images on demand, the img element must return to the unavailable state.

Each img element has a last selected source, which must initially be null, and a current pixel density, which must initially be undefined.

When an img element has a current pixel density that is not 1.0, the element's image data must be treated as if its resolution, in device pixels per CSS pixels, was the current pixel density.

For example, if the current pixel density is 3.125, that means that there are 300 device pixels per CSS inch, and thus if the image data is 300x600, it has an intrinsic dimension of 96 CSS pixels by 192 CSS pixels.

Each Document object must have a list of available images. Each image in this list is identified by a tuple consisting of an absolute URL, a CORS settings attribute mode, and, if the mode is not No CORS, an origin. User agents may copy entries from one Document object's list of available images to another at any time (e.g. when the Document is created, user agents can add to it all the images that are loaded in other Documents), but must not change the keys of entries copied in this way when doing so. User agents may also remove images from such lists at any time (e.g. to save memory).

When the user agent is to update the image data of an img element, it must run the following steps:

  1. Return the img element to the unavailable state.

  2. If an instance of the fetching algorithm is still running for this element, then abort that algorithm, discarding any pending tasks generated by that algorithm.

  3. Forget the img element's current image data, if any.

  4. If the user agent cannot support images, or its support for images has been disabled, then abort these steps.

  5. Otherwise, if the element has a src attribute specified and its value is not the empty string, let selected source be the value of the element's src attribute, and selected pixel density be 1.0. Otherwise, let selected source be null and selected pixel density be undefined.

  6. Let the img element's last selected source be selected source and the img element's current pixel density be selected pixel density.

  7. If selected source is not null, run these substeps:

    1. Resolve selected source, relative to the element. If that is not successful, abort these steps.

    2. Let key be a tuple consisting of the resulting absolute URL, the img element's crossorigin attribute's mode, and, if that mode is not No CORS, the Document object's origin.

    3. If the list of available images contains an entry for key, then set the img element to the completely available state, update the presentation of the image appropriately, queue a task to fire a simple event named load at the img element, and abort these steps.

  8. Asynchronously await a stable state, allowing the task that invoked this algorithm to continue. The synchronous section consists of all the remaining steps of this algorithm until the algorithm says the synchronous section has ended. (Steps in synchronous sections are marked with ⌛.)

  9. ⌛ If another instance of this algorithm for this img element was started after this instance (even if it aborted and is no longer running), then abort these steps.

    Only the last instance takes effect, to avoid multiple requests when, for example, the src and crossorigin attributes are all set in succession.

  10. ⌛ If selected source is null, then set the element to the broken state, queue a task to fire a simple event named error at the img element, and abort these steps.

  11. ⌛ Queue a task to fire a progress event named loadstart at the img element.

  12. ⌛ Do a potentially CORS-enabled fetch of the absolute URL that resulted from the earlier step, with the mode being the current state of the element's crossorigin content attribute, the origin being the origin of the img element's Document, and the default origin behaviour set to taint.

    The resource obtained in this fashion, if any, is the img element's image data. It can be either CORS-same-origin or CORS-cross-origin; this affects the origin of the image itself (e.g. when used on a canvas).

    Fetching the image must delay the load event of the element's document until the task that is queued by the networking task source once the resource has been fetched (defined below) has been run.

    This, unfortunately, can be used to perform a rudimentary port scan of the user's local network (especially in conjunction with scripting, though scripting isn't actually necessary to carry out such an attack). User agents may implement cross-origin access control policies that are stricter than those described above to mitigate this attack, but unfortunately such policies are typically not compatible with existing Web content.

    If the resource is CORS-same-origin, each task that is queued by the networking task source while the image is being fetched must fire a progress event named progress at the img element.

  13. End the synchronous section, continuing the remaining steps asynchronously, but without missing any data from the fetch algorithm.

  14. As soon as possible, jump to the first applicable entry from the following list:

    If the resource type is multipart/x-mixed-replace

    The next task that is queued by the networking task source while the image is being fetched must set the img element's state to partially available.

    Each task that is queued by the networking task source while the image is being fetched must update the presentation of the image, but as each new body part comes in, it must replace the previous image. Once one body part has been completely decoded, the user agent must set the img element to the completely available state and queue a task to fire a simple event named load at the img element.

    The progress and loadend events are not fired for multipart/x-mixed-replace image streams.

    If the resource type and data corresponds to a supported image format, as described below

    The next task that is queued by the networking task source while the image is being fetched must set the img element's state to partially available.

    That task, and each subsequent task, that is queued by the networking task source while the image is being fetched must update the presentation of the image appropriately (e.g. if the image is a progressive JPEG, each packet can improve the resolution of the image).

    Furthermore, the last task that is queued by the networking task source once the resource has been fetched must additionally run the steps for the matching entry in the following list:

    If the download was successful and the user agent was able to determine the image's width and height
    1. Set the img element to the completely available state.

    2. Add the image to the list of available images using the key key.

    3. If the resource is CORS-same-origin: fire a progress event named load at the img element.

      If the resource is CORS-cross-origin: fire a simple event named load at the img element.

    4. If the resource is CORS-same-origin: fire a progress event named loadend at the img element.

      If the resource is CORS-cross-origin: fire a simple event named loadend at the img element.

    そうでなければ
    1. Set the img element to the broken state.

    2. If the resource is CORS-same-origin: fire a progress event named load at the img element.

      If the resource is CORS-cross-origin: fire a simple event named load at the img element.

    3. If the resource is CORS-same-origin: fire a progress event named loadend at the img element.

      If the resource is CORS-cross-origin: fire a simple event named loadend at the img element.

    そうでなければ

    Either the image data is corrupted in some fatal way such that the image dimensions cannot be obtained, or the image data is not in a supported file format; the user agent must set the img element to the broken state, abort the fetching algorithm, discarding any pending tasks generated by that algorithm, and then queue a task to first fire a simple event named error at the img element and then fire a simple event named loadend at the img element.

While a user agent is running the above algorithm for an element x, there must be a strong reference from the element's Document to the element x, even if that element is not in its Document.

When an img element is in the completely available state and the user agent can decode the media data without errors, then the img element is said to be fully decodable.

Whether the image is fetched successfully or not (e.g. whether the response code was a 2xx code or equivalent) must be ignored when determining the image's type and whether it is a valid image.

This allows servers to return images with error responses, and have them displayed.

The user agent should apply the image sniffing rules to determine the type of the image, with the image's associated Content-Type headers giving the official type. If these rules are not applied, then the type of the image must be the type given by the image's associated Content-Type headers.

User agents must not support non-image resources with the img element (e.g. XML files whose root element is an HTML element). User agents must not run executable code (e.g. scripts) embedded in the image resource. User agents must only display the first page of a multipage resource (e.g. a PDF file). User agents must not allow the resource to act in an interactive fashion, but should honor any animation in the resource.

This specification does not specify which image types are to be supported.



What an img element represents depends on the src attribute and the alt attribute.

If the src attribute is set and the alt attribute is set to the empty string

The image is either decorative or supplemental to the rest of the content, redundant with some other information in the document.

If the image is available and the user agent is configured to display that image, then the element represents the element's image data.

Otherwise, the element represents nothing, and may be omitted completely from the rendering. User agents may provide the user with a notification that an image is present but has been omitted from the rendering.

If the src attribute is set and the alt attribute is set to a value that isn't empty

The image is a key part of the content; the alt attribute gives a textual equivalent or replacement for the image.

If the image is available and the user agent is configured to display that image, then the element represents the element's image data.

Otherwise, the element represents the text given by the alt attribute. User agents may provide the user with a notification that an image is present but has been omitted from the rendering.

If the src attribute is set and the alt attribute is not

There is no textual equivalent of the image available.

If the image is available and the user agent is configured to display that image, then the element represents the element's image data.

Otherwise, the user agent should display some sort of indicator that there is an image that is not being rendered, and may, if requested by the user, or if so configured, or when required to provide contextual information in response to navigation, provide caption information for the image, derived as follows:

  1. If the image is a descendant of a figure element that has a child figcaption element, and, ignoring the figcaption element and its descendants, the figure element has no Text node descendants other than inter-element whitespace, and no embedded content descendant other than the img element, then the contents of the first such figcaption element are the caption information; abort these steps.

  2. There is no caption information.

If the src attribute is not set and either the alt attribute is set to the empty string or the alt attribute is not set at all

The element represents nothing.

そうでなければ

The element represents the text given by the alt attribute.

The alt attribute does not represent advisory information. User agents must not present the contents of the alt attribute in the same way as content of the title attribute.

While user agents are encouraged to repair cases of missing alt attributes, authors must not rely on such behavior. Requirements for providing text to act as an alternative for images are described in detail below.

The contents of img elements, if any, are ignored for the purposes of rendering.


usemap属性が存圚する堎合、画像が関連付けられたむメヌゞマップを瀺すこずができる。

href属性を持぀a芁玠の子孫である芁玠で䜿甚される堎合、ismap属性は、芁玠がサヌバヌサむドのむメヌゞマップぞのアクセスを提䟛するこずによっお、その存圚を瀺す。これは、むベントが察応するa芁玠でどのように凊理されるかに圱響する。

ismap属性は真停属性である。属性は、href属性を持぀祖先a芁玠を持たない芁玠に指定しおはならない。

img芁玠は、寞法属性をサポヌトする。

The alt, src IDL attributes must reflect the respective content attributes of the same name.

The crossOrigin IDL attribute must reflect the crossorigin content attribute, limited to only known values.

The useMap IDL attribute must reflect the usemap content attribute.

The isMap IDL attribute must reflect the ismap content attribute.

image . width [ = value ]
image . height [ = value ]

これらの属性は、実際のレンダリングされた画像の倧きさ、たたは寞法が未知である堎合に0を返す。

察応するコンテンツ属性を倉曎するために、蚭定が可胜である。

image . naturalWidth
image . naturalHeight

これらの属性は、画像の内圚寞法、たたは寞法が未知の堎合に0を返す。

image . complete

画像が完党にダりンロヌドされおいる堎合、たたは、䜕も画像が指定されない堎合にtrueを返す。そうでなければ、falseを返す。

image = new Image( [ width [, height ] ] )

該圓する堎合、適切な匕数で枡された倀に蚭定されたwidthずheight属性を持぀、新しいimg芁玠を返す。

The IDL attributes width and height must return the rendered width and height of the image, in CSS pixels, if the image is being rendered, and is being rendered to a visual medium; or else the intrinsic width and height of the image, in CSS pixels, if the image is available but not being rendered to a visual medium; or else 0, if the image is not available. [CSS]

On setting, they must act as if they reflected the respective content attributes of the same name.

The IDL attributes naturalWidth and naturalHeight must return the intrinsic width and height of the image, in CSS pixels, if the image is available, or else 0. [CSS]

The IDL attribute complete must return true if any of the following conditions is true:

Otherwise, the attribute must return false.

The value of complete can thus change while a script is executing.

A constructor is provided for creating HTMLImageElement objects (in addition to the factory methods from DOM such as createElement()): Image(width, height). When invoked as a constructor, this must return a new HTMLImageElement object (a new img element). If the width argument is present, the new object's width content attribute must be set to width. If the height argument is also present, the new object's height content attribute must be set to height. The element's document must be the active document of the browsing context of the Window object on which the interface object of the invoked constructor is found.

4.7.1.1 画像に察しお代替ずしお動䜜するテキストを提䟛に察する芁件

テキストによる代替 [WCAG]は、芖芚情報をアクセシブルにするための最も重芁な方法である。これによりナヌザヌのニヌズに合うように、任意の感芚様匏たずえば、芖芚、聎芚や觊芚を介しおレンダリングできるのである。テキストによる代替を提䟛するこずは、情報をさたざたなナヌザヌ゚ヌゞェントによっお様々な方法でレンダリングするこずを可胜にする。たずえば、画像を芋るこずができない人は、合成音声を䜿甚しおテキストによる代替を読み䞊げさせるこずができる。

画像のalt属性は非垞に重芁なアクセシビリティヌ属性である。有甚なalt属性コンテンツを䜜成するこずは、画像が出珟するコンテキストおよびそのコンテキストにおいお画像が持っおもよい機胜を著者に泚意深く考慮するこずを芁求する。ここを含むガむダンスは、著者が画像を䜿甚するもっずも䞀般的な方法を扱う。远加のガむダンスおよびテクニックはResources on Alternative Text for Imagesで利甚可胜である。

4.7.1.1.1 ナヌザヌが画像のテキストによる代替の恩恵を受けるシナリオの䟋
4.7.1.1.2 䞀般的なガむドラむン

特に指定されおいる堎合を陀き、alt属性を指定しなければならず、その倀が空であっおはならない。倀は画像に察しお適切な眮換でなければならない。alt属性に察する具䜓的な芁件は、以䞋の節で説明するように、ペヌゞでの画像の機胜に䟝存する。

適切なテキストによる代替を刀断するために、画像がペヌゞに含たれおいる理由を考えるこずが重芁である。その目的は䜕かこのように考えるこずは、読者に意図する画像に関しお䜕が重芁かを理解するのに圹立぀。すべおの画像は、有甚な情報を提䟛する、機胜を実行する、むンタラクティブな芁玠を分類する、矎意識を高めるたたは玔粋に装食的ずいったペヌゞ䞊に存圚する理由を持぀。したがっお、画像が䜕のために存圚するのかを理解するこずは、適切なテキストによる代替の蚘述を容易にする。

ハむパヌリンク、たたはbutton芁玠をも぀a芁玠が、テキストコンテンツがないが1぀以䞊の画像を含む堎合、alt属性がリンクやボタンの目的を同時に䌝えるテキストを含む。

この䟋では、ナヌザヌは、3぀のリストから奜みの色を遞択するよう求められおいる。画像によっおそれぞれの色は䞎えられるが、画像を衚瀺できないナヌザヌのために、画像のalt属性の䞭に色の名前が含たれおいる。

HTMLコヌド䟋は、ブラりザに衚瀺される。長方圢の画像を含む3぀のリンク、それぞれは、1が'青'、2が'èµ€'、3が'緑'のテキストを持぀。

  <ul>
  <li><a href="red.html"><img src="red.jpeg" alt="Red"></a></li>
  <li><a href="green.html"><img src="green.jpeg" alt="Green"></a></li>
  <li><a href="blue.html"><img src="blue.jpeg" alt="Blue"></a></li>
  </ul>
  

この䟋では、a芁玠のリンクはロゎを含む。リンクは倖郚サむトからW3Cのりェブサむトを指す。テキストによる代替はリンク先の簡単な説明である。

W3C logo used as link content.

  <a href="http://w3.org">
  <img src="images/w3c_home.png" width="72" height="48" alt="W3C web site">
  </a>
  

リンクがW3Cのりェブサむトにあるこずを陀いお、この䟋は前の䟋ず同じである。テキストによる代替はリンク先の簡単な説明である。

W3C logo used as link content.

  <a href="http://w3.org">
  <img src="images/w3c_home.png" width="72" height="48" alt="W3C home">
  </a>
  

ロゎの画像を䜿甚するコンテキストに䟝存するこずは、画像がテキストによる代替の䞀郚ずしおのロゎであるこずの指瀺を提䟛するために適切だろう。4.7.1.1.19 ロゎ、蚘号、旗、たたぱンブレムの節を参照のこず。

この䟋においお、a芁玠のリンクがプレビュヌアむコンを含む。リンクは印刷甚スタむルシヌトを適甚するペヌゞを指す。テキストによる代替はリンク先の簡単な説明である。

Print preview icon used as link content.

  <a href="preview.html">
  <img src="images/preview.png" width="32" height="30" alt="Print preview.">
  </a>
  

この䟋で、ボタンは怜玢アむコンを含んでいる。ボタンは怜玢フォヌムを送信する。テキストによる代替はボタンが䜕をするかの簡単な説明である。

Search icon used as button content.

  <button>
  <img src="images/search.png" width="74" height="29" alt="Search">
  </button>
  

この䟋においお、PIP瀟の䌚瀟のロゎは2぀の画像に分割されおおり、1枚目は単語PIPを含み、2枚目は略語COをも぀。画像は、PIPCOのホヌムペヌゞぞのリンクに属する唯䞀のコンテンツである。この堎合、リンク先の簡単な説明が提䟛される。単䞀の実䜓ずしお画像はナヌザヌに提䟛されるので、最初の画像のalt属性におけるテキストによる代替はPIP CO homeである。

Image containing the text 'PIP'.Image containing the text 'CO'.

  <a href="pipco-home.html">
  <img src="pip.gif" alt="PIP CO home"><img src="co.gif" alt="">
  </a>
  
4.7.1.1.4 グラフィカルな衚珟チャヌト、図、グラフ、マップ、むラスト

たずえばフロヌチャヌト、図衚、グラフ、たたは方角を瀺す地図などずしお、グラフ圢匏でコンテンツが衚瀺される際にナヌザヌは恩恵を受けるだろう。グラフ圢匏で提瀺されるコンテンツもテキスト圢匏で提䟛される堎合、ナヌザヌもたた利益を埗る。このナヌザヌは、画像を衚瀺できない人たちを含む。たずえば、非垞に䜎速な接続である、たたはテキストのみのブラりザを䜿甚しおいる、たたはハンズフリヌ自動車音声りェブブラりザによっお読み出されるペヌゞを聞いおいる、あるいは、芖芚障害を持ち、テキストを音声にレンダリングする支揎技術䜿甚しおいるため。

次の円グラフの画像䟋においお、円グラフに衚瀺されるデヌタを衚すalt属性でテキストをも぀

Browser Share: Internet Explorer 25%, Firefox 40%, Chrome 25%, Safari 6% and Opera 4%.

  <img src="piechart.gif" alt="Pie chart: Browser Share - Internet Explorer 25%, Firefox 40%, Chrome 25%, Safari 6% and Opera 4%.">
  

この堎合、グラフィカルな圢匏で画像が前の段萜を繰り返す。alt属性コンテンツは画像を分類する。

 <p>According to a recent study Firefox has a 40% browser share, Internet Explorer has 25%, Chrome has 25%, Safari has 6% and Opera has 4%.</p>
 <p><img src="piechart.gif" alt="Pie chart representing the data in the previous paragraph."></p>

たずえばsrc属性倀が間違っおいるため、画像が利甚できない堎合に、テキストによる代替が画像コンテンツの簡単な説明をナヌザヌに提䟛するのが芋られる

Representation of the code snippet above.

テキストによる代替が長くなる堎合においお、1぀以䞊の文は、構造化マヌクアップを䜿甚するこずの恩恵を受けるだろう、簡単な説明たたはalt属性を䜿甚するラベル、および関連付けられた代替テキストを提䟛する。

これは、alt属性に含たれる短いテキストによる代替をもフロヌチャヌト画像の䟋である。この堎合、テキストによる代替は画像が唯䞀のリンク内容ずしおリンク先の説明ずなる。リンクは、フロヌチャヌトで衚されるプロセスの、同じ文曞の䞭で説明を指す。

Flowchart: Dealing with a broken lamp.

  
  <a href="#desc"><img src="flowchart.gif" alt="Flowchart: Dealing with a broken lamp."></a>

  ...

  ...

  <div id="desc">
  <h2>Dealing with a broken lamp</h2>
  <ol>
  <li>Check if it's plugged in, if not, plug it in.</li>
  <li>If it still doesn't work; check if the bulb is burned out. If it is, replace the bulb.</li>
  <li>If it still doesn't work; buy a new lamp.</li>
  </ol>
  </div>

この䟋では、グラフの画像が存圚する。情報がデヌタ集合であるため、alt属性でプレヌンテキストによる代替ずしおグラフに瀺される情報を提䟛するこずは䞍適切である。グラフ画像で衚されるデヌタを䜿甚するデヌタテヌブルの圢匏で画像の䞋に、構造化されたテキストによる代替が代わりに提䟛される。

Bar Chart showing average rainfall in millimetres by Country and Season.

各シヌズンの最高および最䜎降雚の衚瀺が衚に含たれおいるため、グラフで容易に識別される傟向がデヌタテヌブルにも利甚できる。

Average rainfall in millimetres by country and season.
United KingdomJapanAustralia
Spring5.3 (highest)2.42 (lowest)
Summer4.5 (highest)3.42 (lowest)
Autumn3.5 (highest)1.81.5 (lowest)
Winter1.5 (highest)1.21 (lowest)
  <figure>
  <figcaption>Rainfall Data</figcaption>
  <img src="rainchart.gif" alt="Bar chart: Average rainfall in millimetres by Country and Season.">
  <table>
  <caption>Rainfall in millimetres by Country and Season.</caption>
  <tr><td><th scope="col">UK <th scope="col">Japan<th scope="col">Australia</tr>
  <tr><th scope="row">Spring <td>5.5 (highest)<td>2.4 <td>2 (lowest)</tr>
  <tr><th scope="row">Summer <td>4.5 (highest)<td>3.4<td>2 (lowest)</tr>
  <tr><th scope="row">Autumn <td>3.5 (highest) <td>1.8 <td>1.5 (lowest)</tr>
  <tr><th scope="row">Winter <td>1.5 (highest) <td>1.2 <td>1 lowest</tr>
  </table>
  </figure>
  

figure芁玠は、棒グラフ画像およびデヌタのテヌブルをグルヌプ化するために䜿甚される。figcaption芁玠は、グルヌプ化されたコンテンツに察するキャプションを提䟛する。

4.7.1.1.5 テキストの画像

時ずしお画像はテキストのみを含み、そしお画像の目的は、芖芚効果ずフォントの䞡方たたはいずれか䞀方を利甚するテキストを衚瀺するこずにある。CSSを甚いたスタむル付きテキストを䜿甚するこずを匷く掚奚するが、これが䞍可胜な堎合、画像であるがたたにalt属性で同じテキストを提䟛する。

この䟋は、テキストの画像を"Get Happy!"ず衚瀺する。掟手な色ずりどりのフリヌハンド颚に曞かれおいる。画像は芋出しの内容を構成する。この䟋においお、画像のテキストによる代替は"Get Happy!"ずすべきである。

Get Happy!

<h1><img src="gethappy.gif" alt="Get Happy!"></h1>

この䟋では、テキストからなる広告画像であり、フレヌズ"The BIG sale"が3回繰り返され、回を重ねるごずにテキストはより小さくか぀より暗くなり、最埌の行は"...ends Friday"ず読む。広告ずしお、コンテキストにおける䜿甚は、画像のテキストによる代替は䞀床だけテキスト"The BIG sale"を含むこずが掚奚される。芖芚効果ずテキストの繰り返しは、画像が衚瀺できないナヌザヌにずっお䞍芁であり、混乱を招くかもしれない。

The big sale ...ends Friday.

  <p><img src="sale.gif" alt="The BIG sale ...ends Friday."></p>
  

テキストの画像ず䞀緒に写真たたは他のグラフィックも存圚する状況においお、情報がたた画像を衚瀺できないナヌザヌにも䜿甚できるように、画像を衚瀺できるナヌザヌに意味を䌝える画像の他の説明ずずもに、テキストによる代替に含たれおいる画像テキスト内の単語を保蚌する。

画像がUnicodeで衚珟できない文字を衚すために別の方法で䜿甚される堎合、たずえば倖字、異䜓字、たたは新芏の通貚蚘号のような新しい文字においお、テキストによる代替は、たずえば、文字の発音を䞎えるために衚音のひらがなやカタカナを䜿甚するなど、同じものを蚘述するより䌝統的な方法であるべきである。

1997幎からのこの䟋においお、䞭倮の2぀のバヌずずもに枊巻き状のEのように芋える最新匏の通貚蚘号のかわりに、画像を䜿甚しお衚珟される。代替テキストは、文字の発音を䞎える。

Only euro 5.99!

<p>Only <img src="euro.png" alt="euro ">5.99!

Unicode文字が同じ目的を果たすならば画像を䜿甚すべきでない。たずえば装食のためや、文字がUnicode文字集合にない倖字の堎合のような文字であるためなど、テキストが盎接Unicodeを䜿甚しお衚すこずができない堎合にのみ、画像が適切だろう。

デフォルトのシステムフォントが指定された文字をサポヌトしないため、著者が画像を䜿甚するように誘惑される堎合、りェブフォントは画像よりも優れた解決策である。

装食写本は、その文字の䞀郚のグラフィックスを䜿甚するかもしれない。このような状況でテキストによる代替は、単に画像が衚す文字である。

Once upon a time and a long long time ago...

<p><img src="initials/fancyO.png" alt="O">nce upon a time and a long long time ago...
4.7.1.1.6 テキストを含む画像

時ずしお、画像はグラフおよび関連するテキストのようなグラフィックスを構成する。この堎合、テキストによる代替に画像内のテキストを含めるこずを掚奚する。

円グラフず関連するテキストを含む画像を考えおみる。テキストの画像でなく、任意の関連するテキストを可胜な限りテキストずしお提䟛するこずを掚奚する。これが䞍可胜な堎合、画像で䌝えられる関連情報ずずもにテキストによる代替内のテキストを含む。

Figure 1. Distribution of Articles by Journal 
  Category. Pie chart: Language=68%, Education=14% and Science=18%.

  <p><img src="figure1.gif" alt="Figure 1. Distribution of Articles by Journal Category.
  Pie chart: Language=68%, Education=14% and Science=18%."></p>
  

同じ円グラフの画像のもう1぀の䟋では、alt属性ず長い代替テキストに含たれる短いテキストによる代替を衚瀺する。figureおよびfigcaption芁玠は、画像ずより長いテキストによる代替を関連付けるために䜿甚される。alt属性は、画像にラベル付けするために䜿甚される。

  <figure>
  <img src="figure1.gif" alt="Figure 1">
  <figcaption><strong>Figure 1.</strong> Distribution of Articles by Journal Category.
  Pie chart: Language=68%, Education=14% and Science=18%.</figcaption>
  </figure>
  

前の䟋ず比べたこの方法の利点は、テキストによる代替が垞にすべおのナヌザヌに利甚可胜であるこずにある。たた、テキストによる代替がalt属性を䜿甚しお提䟛されない堎所で、テキストによる代替で䜿甚されるために構造化されたマヌクアップを蚱可する。

4.7.1.1.7 テヌマを向䞊させる画像やペヌゞ内容の䞻題

呚囲のテキストで盎接議論されないが、䟝然ずしお䞀郚の関連性を持぀画像はimg芁玠を䜿甚しお、ペヌゞに含めるこずが可胜である。このような画像は単なる装食以䞊のものであり、テヌマやペヌゞ内容の䞻題を補匷するので、内容の䞀郚を盞倉わらず圢成するこずがある。この堎合、テキストによる代替を提䟛するこずを掚奚する。

これはペヌゞ内容の䞻題に密接に関連するが、盎接説明されない画像の䞀䟋である。その詩の暗唱ペヌゞで、詩に觊発された絵の画像である。次の断片は䟋を瀺す。画像は、"Lady of Shallot"シャロットの貎婊人ず題した絵画であり、絵は詩に觊発され、絵の䞻題は詩から掟生しおいる。したがっお、テキストによる代替が提䟛されるこずを匷く掚奚する。alt属性に画像の内容の短い説明があり、文の䞋に長い説明ぞのリンクがある。長い説明の最埌に絵に぀いおの詳しい情報ぞのリンクもある。

アルフレッド・テニスンの詩シャロットの貎婊人に觊発された絵

  <header>
  <h1>The Lady of Shalott</h1>
  <p>A poem by Alfred Lord Tennyson</p>
  </header>

  <img src="shalott.jpeg" alt="Painting of a  young woman with long hair, sitting in a wooden boat. ">
  <p><a href="#des">Description of the painting</a>.</p>


  <!-- Full Recitation of Alfred, Lord Tennyson's Poem.  -->

  ...
  ...
  ...
  <p id="des">The woman in the painting is wearing a flowing white dress. A large piece of intricately 
  patterned fabric is draped over the side. In her right hand she holds the chain mooring the boat. Her expression 
  is mournful. She stares at a crucifix lying in front of her. Beside it are three candles. Two have blown out. 
  <a href="http://bit.ly/5HJvVZ">Further information about the painting</a>.</p>
  

この䟋は、ペヌゞの䞻題の写真ずしお画像を識別するテキストによる代替の提䟛を説明する。

Portrait photo(black and white) of Robin, accompanied by a heading 'Robin Berjon' and a question
    'what more needs to be said?'
    <img src="orateur_robin_berjon.png" alt="Portrait photo(black and white) of Robin.">
    <h1>Robin Berjon</h1>
    <p>What more needs to be said?</p>
    
4.7.1.1.8 呚囲のテキストの䞀郚をグラフィカルに衚珟

倚くの堎合、画像は実際には単なる補足であり、その存圚は単に呚囲のテキストを匷調するだけである。この堎合、alt属性が存圚しなければならないが、その倀は空文字列でなければならない。

䞀般に画像は、画像を削陀しおもペヌゞの有甚性が匱たるわけでない堎合にこのカテゎリに分類されるが、画像を含めるこずは、芖芚ブラりザのナヌザヌにずっお抂念を理解するこずがはるかに容易になる。

画像の有甚なテキストによる代替を蚘述するこずは必ずしも容易ではない。別のオプションは、画像に぀いおの詳しい情報ぞのリンクを提䟛するこずである。

同じ画像のこの䟋では、alt属性に含たれる短いテキストによる代替があり、画像の埌にリンクがある。リンクは絵に関する情報を含むペヌゞを指す。

The Lady of Shalott
A poem by Alfred Lord Tennyson.

小さなボヌトに座る、癜い流れるようなドレスの女性の絵。

About this painting.

Full recitation of Alfred, Lord Tennyson's poem.

  <header><h1>The Lady of Shalott</h1>
  <p>A poem by Alfred Lord Tennyson</p></header>
  <figure>
  <img src="shalott.jpeg" alt="Painting of a woman in a white flowing dress, sitting in a small boat.">
  <p><a href="http://bit.ly/5HJvVZ">About this painting.</a></p>
  </figure>
  <!-- Full Recitation of Alfred, Lord Tennyson's Poem.  -->
  
4.7.1.1.9 情報を远加しない、玔粋に装食的な画像

玔粋に装食的な画像は、芖芚的な機胜匷化や装食、画像を衚瀺できるナヌザヌぞの矎意識を超えた機胜や情報を提䟛しない装食である。

空のalt属性alt=""を䜿甚するこずによっお支揎技術が無芖できるように、玔粋に装食的な画像をマヌクアップする。装食的な画像をむンラむンで含むこずが受け入れられないこずはないが、CSSを䜿甚した画像を含むために玔粋に装食的であるこずが掚奚される。

ある人のブログの装食バナヌずしお䜿甚される画像の䟋では、画像は䜕も情報を提䟛しないので、空のalt属性を持぀べきである。

Clara's Blog

Welcome to my blog...

  <header>
  <div><img src="border.gif" alt="" width="400" height="30"></div>
  <h1>Clara's Blog</h1>
  </header>
  <p>Welcome to my blog...</p>
  
4.7.1.1.10 むンラむン画像

画像が文曞でテキストの流れの䞀郚ずしおむンラむンで䜿甚される堎合、離れおいる文曞の文脈で理にかなったテキストによる代替ずしお単語たたはフレヌズを提䟛する。

I love you.

I <img src="heart.png" alt="love"> you.

My heart breaks.

My <img src="heart.png" alt="heart"> breaks.

画像が小さな画像ファむルに分割されおいる堎合、再床完党な画像を圢成するために䞀緒に衚瀺され、党䜓ずしお画像に関連するガむダンスに埓っおalt属性を䜿甚する画像のいずれかに察するテキストによる代替を含み、そしお他の画像で空のalt属性を含む。

この䟋においお、PIP瀟の䌚瀟のロゎを衚す絵が2枚に分割されおおり、1枚目は文字"PIP"を含み、2枚目は単語"CO"を持぀。代替テキストPIP COは最初の画像のalt属性にある。

Image containing the text 'PIP'.Image containing the text 'CO'.

  <img src="pip.gif" alt="PIP CO"><img src="co.gif" alt="">
  

次の䟋においお、評䟡は、3぀の塗り぀ぶされた星ず、2぀の䞭抜きの星ずしお瀺される。テキストによる代替は"★★★☆☆"かもしれないが、代わりに著者は、より芪切な圢匏"3 out of 5"の評䟡を䞎えるようにした。これは最初の画像のテキストによる代替であり、残りは空のalt属性を持぀。

3 out of 5.

  <p>Rating: <meter max=5 value=3>
  <img src="1" alt="3 out of 5">
  <img src="1" alt=""><img src="1" alt="">
  <img src="0" alt=""><img src="0" alt="">
  </meter></p>
  
4.7.1.1.12 むメヌゞマップ
img芁玠が、href属性を持぀area芁玠を含むmap芁玠を参照するusemap属性を持぀堎合、imgはむンタラクティブコンテンツであるず芋なされる。このような堎合、alt属性を䜿甚しお画像のテキストによる代替を垞に提䟛する。

カトゥヌンバの地図である以䞋の画像を考える。地図が南北カトゥヌンバの領域に察応する2぀のむンタラクティブ領域を持぀。

Map of Katoomba.

North KatoombaSouth Katoomba

テキストによる代替は、画像の簡単な説明である。各area芁玠のalt属性は、それぞれリンクされた地域のタヌゲットペヌゞのコンテンツを説明するテキストを提䟛する。

<p>View houses for sale in North Katoomba or South Katoomba:</p>
 <p><img src="imagemap.png" width="209" alt="Map of Katoomba" height="249" usemap="#Map">

 <map name="Map"> 
 <area shape="poly" coords="78,124,124,10,189,29,173,93,168,132,136,151,110,130" 
 href="north.html" alt="Houses in North Katoomba">
 <area shape="poly" coords="66,63,80,135,106,138,137,154,167,137,175,133,144,240,49,223,17,137,17,61" 
 alt="Houses in South Katoomba" href="south.html">
 </map> 

䞀般にむメヌゞマップは、リンク甚の画像をスラむスする代わりに䜿甚されるべきである。

耇数画像から合成写真を䜜成する堎合、画像の1぀以䞊をリンクしたいず思うかもしれない。リンクの目的を説明するために、各リンクされた画像に察しおalt属性を提䟛する。

次の䟋においお、合成写真は"Crocoduck"を瀺すために䜿甚される。これは、ワニの䞀郚ずアヒルの䞀郚によっお進化の原則を無芖する架空の生き物である。Crocoduckず亀流するように求めおいるが、甚心する必芁がある。

crocodile's angry, chomping headduck's soft, feathery body

  <h1>The crocoduck</h1>
  <p>You encounter a strange creature called a "crocoduck".
  The creature seems angry!Perhaps some friendly stroking will help to calm
  it, but be careful not to stroke any crocodile parts. This would just enrage
  the beast further.</p>
  <a href="?stroke=head"><img src="crocoduck1.png" alt="Stroke crocodile's angry, chomping head"></a>
  <a href="?stroke=body"><img src="crocoduck2.png" alt="Stroke duck's soft, feathery body"></a>  
  
4.7.1.1.14 写真の画像

写真やグラフィックス画像は、芖芚オブゞェクトの衚珟、人、颚景、抜象化などが含たれる。この非テキストコンテンツ [WCAG] は、芖芚的に倧量の情報を䌝えるか、晎県者に特定の感芚的な䜓隓 [WCAG]を提䟛できる。䟋ずしおは、写真、絵画、図面やアヌトワヌクが含たれる。

画像に察する適切なテキストによる代替は、簡単な説明たたは識別名である[WCAG]。すべおのテキストによる代替のオヌサリング刀定のように、画像に察しお適切なテキストによる代替を曞くこずは人間の刀断を必芁ずする。テキスト倀は、画像が䜿甚されるコンテキストずペヌゞ䜜者の文䜓の䞻芳的なものである。したがっお、特定の画像に察するaltテキストの'正しい'ものはない。非テキストコンテンツの簡単な説明を䞎える短いテキストによる代替の提䟛に加えお、適切な有甚である堎合にも別のものを介しお補足的コンテンツの提䟛を意味する。

この䟋は、写真共有サむトにアップロヌドした画像を瀺す。写真は颚呂に座っおいる猫である。画像は、img芁玠のalt属性を甚いお提䟛されるテキストによる代替を持぀。たた、figure芁玠およびキャプションテキストを識別するためのfigcaption芁玠を䜿甚したものでimg芁玠を含むこずで、キャプションを提䟛する。

ロヌラ猫はお颚呂の济槜に傘の䞋で座っおいる。

Lola prefers a bath to a shower.

  <figure>
  <img src="664aef.jpg" alt="Lola the cat sitting under an umbrella in the bath tub.">
  <figcaption>Lola prefers a bath to a shower.</figcaption>
  </figure>
  

画像の䞻題が解釈が自由であるため、この䟋は完党な蚘述を受け付けない画像である。画像を衚瀺できないナヌザヌにどのような画像であるかを提䟛するalt属性でテキストによる代替を画像は持぀。画像はたた、figure芁玠においおimg芁玠を含む、およびキャプションテキストを識別するためにfigcaption芁玠を䜿甚するこずによっお、提䟛されるキャプションも持぀。

An abstract, freeform, vertically symmetrical, black inkblot on a light background.

ロヌルシャッハテストにおける10枚のカヌドの最初のもの。

<figure>
  <img src="Rorschach1.jpg" alt="An abstract, freeform, vertically symmetrical, black inkblot on a light background.">
  <figcaption>The first of the ten cards in the Rorschach test.</figcaption>
  </figure> 
4.7.1.1.15 りェブカメラ画像

りェブカメラの画像は、自動で定期的に曎新される静的な画像である。䞀般に画像は固定された堎所からのものであり、それぞれ新しい画像がカメラからアップロヌドされるか、たたはナヌザヌが曎新された画像を衚瀺ためにペヌゞを再読み蟌みする必芁があるので、画像は自動的にペヌゞ䞊で曎新しおもよい。䟋ずしおは、亀通および倩気カメラなどがある。

この䟋はかなり兞型的である。タむトルずタむムスタンプは画像に含たれ、自動的にりェブカメラの゜フトりェアによっお生成される。テキスト情報が画像に含たれおいなかった堎合により良いが、テキスト情報は画像の䞀郚であるので、テキストによる代替の䞀郚ずしおテキスト情報を含む。キャプションはたた、figureおよびfigcaption芁玠を䜿っお提䟛される。画像は建物近くの珟圚の倩気に぀いお芖芚情報を䌝えるために提䟛されるが、りェブカメラの画像が自動的に生成されおアップロヌドされるので、地元の倩気予報が提䟛されるリンクが、テキストによる代替ずしおそのような情報を提䟛するこずは実甚的でないだろう。

alt属性のテキストは、音声゜フトりェアぞのテキストによっお知らせる堎合にテキストをよりわかりやすくするために蚭蚈された、タむムスタンプの単調なバヌゞョンを含む。気象条件ず日時が倉化するにもかかわらず、テキストによる代替はたた、倉化しない画像で芋られるこずの䞀郚の偎面の蚘述を含む。

゜ッピヌス家の気象カメラ。Taken on the 21/04/10 at 11:51 and 34 seconds. In the foreground are the safety
  rails on the flat part of the roof. 近くに䜎局の工業甚建物があり、向こうに平らなブロックがある。In the distance there's a
  church steeple.

View from the top of Sopwith house, looking towards North Kingston. This image is updated every hour.

View the latest weather details for Kingston upon Thames.

<figure>
  <img src="webcam1.jpg" alt="Sopwith house weather cam. Taken on the 21/04/10 at 11:51 and 34 seconds.
  In the foreground are the safety rails on the flat part of the roof. Nearby there are low rise industrial buildings,
  beyond are blocks of flats. In the distance there's a church steeple.">
  <figcaption>View from Sopwith house, looking towards north Kingston. This image is updated every hour.</figcaption>
  </figure>
  <p>View the <a href="http://news.bbc.co.uk/weather/forecast/4296?area=Kingston">latest weather details</a> for Kingston upon Thames.</p>
  
4.7.1.1.16 公開時にテキストによる代替が利甚䞍胜である堎合

䞀郚のケヌスにおいお、画像は公開された文曞に含たれるが、著者が適切なテキストによる代替を提䟛するこずができない。このような堎合における最小芁件は、以䞋の条件のもずでfigureおよびfigcaption芁玠を甚いお画像のキャプションを提䟛するこずである。

蚀い換えれば、figureの最良のコンテンツは、img芁玠ずfigcaption芁玠であり、か぀figcaption芁玠はキャプションコンテンツを含たなければならない。

そのような堎合は最小限に保たれるべきである。実際の代替テキストを提䟛する胜力を有する著者のわずかな可胜性がある堎合、alt属性の省略を蚱容しないだろう。

この䟋においお、写真共有サむトに倚数の画像のようなバルクアップロヌドの䞀郚ずしお、ある人が写真をアップロヌドする。ナヌザヌは、テキストによる代替たたは画像のキャプションを提䟛しおいない。サむトのオヌサリングツヌルは、画像に察しお持っおいる有甚な情報を䜿っおキャプションを自動的に挿入する。この堎合においお、それはファむル名および、写真が撮圱された日付である。

no text alternative provided

clara.jpg, taken on 12/11/2010.

  <figure>
  <img src="clara.jpg">
  <figcaption>clara.jpg, taken on 12/11/2010.</figcaption>
  </figure>
  

この䟋ですら、できる限り倚くの有甚な情報が䟝然ずしおfigcaption芁玠に含たれるこずに泚意する。

次の2番目の䟋においお、ある人が写真共有サむトに写真をアップロヌドする。圌女は、テキストによる代替でなく、画像のキャプションを提䟛しおいる。サむトはalt属性でテキストによる代替を远加する機胜をナヌザヌに提䟛しおいないため、この可胜性がある。

no text alternative provided

Eloisa with Princess Belle

  <figure>
  <img src="elo.jpg">
  <figcaption>Eloisa with Princess Belle</figcaption>
  </figure>
  

時ずしお画像党䜓の芁点は、テキストの説明が利甚できず、ナヌザヌが説明を提䟛する。もう䞀぀の䟋は、画像を衚瀺し、正しい代替テキストをも぀ペヌゞを曞く目的に察しお正確に代替テキストを求める゜フトりェアだろう。そのようなペヌゞは次のように、画像のテヌブルを持぀こずができる

<table>
  <tr><tr> <th> Image <th> Description<tr>
  <td>
  <figure>
  <img src="2421.png">
  <figcaption>Image 640 by 100, filename 'banner.gif'</figcaption>
  </figure>
  <td> <input name="alt2421">
  <tr>
  <td> <figure>
  <img src="2422.png">
  <figcaption>Image 200 by 480, filename 'ad3.gif'</figcaption>
  </figure>
  <td> <input name="alt2422">
  </table>

たずえば目が芋えないため、など䞀郚のナヌザヌは䞀切画像を䜿甚するこずができないので、alt属性は、䞊蚘の䟋のように、党くテキストによる代替が利甚できず、誰も利甚できない際に省略するこずが蚱可される。

4.7.1.1.17 ナヌザヌを意図しない画像

䞀般に、著者は画像を衚瀺する以倖の目的でimg芁玠を䜿甚するこずは避けるべきである。

たずえばペヌゞビュヌをカりントするサヌビスの䞀郚ずしお甚いるなど、画像を衚瀺する以倖の目的でimg芁玠を䜿甚する堎合、空のalt属性を䜿甚する。

りェブペヌゞの統蚈情報を収集するために䜿甚されるimg芁玠の䟋を瀺す。画像に意味がないのでalt属性は空である。

  <img src="http://server3.stats.com/count.pl?NeonMeatDream.com" width="0" height="0" alt="">
  

䞊蚘䟋のように0に蚭定するwidthおよびheight属性を䜿甚するよう掚奚される。

もう1぀の甚䟋は、spacer.gifのような画像がコンテンツの䜍眮決めを補助するために䜿甚される堎合である。画像に意味がないのでalt属性は空である。

  <img src="spacer.gif" width="10" height="10" alt="">
  

img芁玠の代わりにCSSコンテンツを配眮しお䜿甚するこずを掚奚する。

4.7.1.1.18 アむコン画像

アむコンは通垞、プログラム、アクション、デヌタファむルや抂念を衚す単玔な絵である。アむコンは、芖芚ブラりザのナヌザヌに䞀目で機胜を認識するのを助けるこずを意図する。

アむコンが同じ意味を䌝えるテキストを補足する際に空のalt属性を䜿甚する。

この䟋では、サむトのホヌムペヌゞを指すリンクは、家のアむコン画像ずテキスト"home"を含む。画像は、空のaltテキストを持぀。画像がこの方法で䜿甚される堎合、CSSを䜿甚しお画像を远加するこずが適切でもあるだろう。

A house icon next to the word 'home'.

  <a href="home.html"><img src="home.gif" width="15" height="15" alt="">Home</a>
  
  #home:before
  { 
  content: url(home.png);
  }

  <a href="home.html" id="home">Home</a>
  

この䟋では、譊告アむコンを䌎う譊告メッセヌゞを衚瀺しおいる。単語"Warning!"はアむコンの次の匷調テキストである。アむコンによっお䌝えられる情報が冗長であるため、img芁玠は空のalt属性が䞎えられる。

Warning!Warning! Your session is about to expire.

  <p><img src="warning.png" width="15" height="15" alt="">
  <strong>Warning!</strong> 
  Your session is about to expire</p>
  

アむコンがテキストで䜿甚できない远加情報を䌝える堎合、テキストによる代替を提䟛する。

この䟋では、譊告アむコンを䌎う譊告メッセヌゞを衚瀺しおいる。アむコンはメッセヌゞの重芁性を匷調し、特定の内容型ずしお識別する。

Warning!Your session is about to expire.

  <p><img src="warning.png" width="15" height="15" alt="Warning!">
  Your session is about to expire</p>
  
4.7.1.1.19 ロゎ、 蚘号、旗、たたぱンブレム

倚くのペヌゞは、䌚瀟、組織、プロゞェクト、バンド、゜フトりェアパッケヌゞ、囜、たたはその他団䜓を衚すロゎ、蚘号、旗、たたぱンブレムを含む。適切なテキストによる代替ずしお考えるこずができるものは、すべおの画像のように、䜿甚されおいる画像におけるコンテキスト、䞎えられたコンテキストで圹立぀機胜に䟝存する。

ロゎがリンクの唯䞀のコンテンツである堎合、alt属性でリンク先の簡単な説明を提䟛する。

この䟋は、HTML仕様ぞリンクの唯䞀のコンテンツずしお、HTML5ロゎの䜿甚方法を瀺す。

HTML 5.1 Nightly specification

  <a href="http://dev.w3.org/html5/spec/spec.html">
  <img src="HTML5_Logo.png" alt="HTML 5.1 specification"></a>
  

たずえばペヌゞの芋出しのように、ロゎが団䜓を衚すために䜿甚されおいる堎合、テキストによる代替ずしおはロゎによっお衚されるその団䜓の名前を提䟛する。

この䟋は、自身を衚珟するために䜿甚されおいるWebPlatform.orgロゎの䜿甚を瀺す。

WebPlatform.org and other developer resources

  <h2><img src="images/webplatform.png" alt="WebPlatform.org"> and other developer resources<h2>
  

䞊蚘の䟋におけるテキストによる代替はたた、画像コンテンツのタむプを説明するために単語"logo"を含むかもしれない。そのような堎合、この情報を衚珟するために角括匧を甚いるこずが提案されるalt="[logo] WebPlatform.org".

ロゎが衚すものの名前の暪にロゎが䜿甚される堎合、そのロゎは補足である。テキストによる代替がすでに提䟛されおいるように空のalt属性を含める。

この䟋は、ロゎが衚す組織名の暪にロゎマヌクの䜿甚を瀺す。

WebPlatform.org

  <img src="images/webplatform1.png" alt=""> WebPlatform.org
  

ロゎが衚す䞻題たたは団䜓を説明するテキストず同時にロゎが䜿甚される堎合、ロゎを説明するテキストによる代替を提䟛する。

この䟋は、ロゎが衚す䞻題を説明するテキストの暪にロゎの䜿甚方法を瀺す。

HTML5 logo: Shaped like a shield with the 
  text 'HTML' above and the numeral '5' prominent on the face of the shield.

HTML5 is a language for structuring and presenting content for the World Wide Web, a core technology of the Internet. It is the latest revision of the HTML standard (originally created in 1990 and most recently standardized as HTML4 in 1997) and currently remains under development. Its core aims have been to improve the language with support for the latest multimedia while keeping it easily readable by humans and consistently understood by computers and devices (web browsers, parsers etc.).

  <p><img src="HTML5_Logo.png" alt="HTML5 logo: Shaped like a shield with the
  text 'HTML' above and the numeral '5' prominent on the face of the shield."></p>
  
  Information about HTML5
4.7.1.1.20 CAPTCHA画像

CAPTCHAキャプチャは、"Completely Automated Public Turing test to tell Computers and Humans Apart"コンピュヌタず人間を区別する完党に自動化された公開チュヌリングテストの略である。CAPTCHA 画像は、コンテンツがコンピュヌタではなく人間によっおアクセスされおいるこずを確認する、セキュリティヌ目的のために䜿甚される。この認蚌は、画像の芖芚的な怜蚌を介しお行われる。CAPTCHAは䞀般的に、文字や単語をも぀画像を提瀺し、ナヌザヌがそれを入力する。画像は通垞、歪められおおり、文字を読解困難にするために適甚されるノむズを持぀。

CAPTCHAのアクセシビリティヌを改良するこずは画像の目的を識別しお説明するテキストによる代替を提䟛し、知芚のさたざたな皮類の出力モヌドを䜿甚するCAPTCHAの代替圢匏を提䟛する。たずえば、芖芚的な画像ずずもに音声代替手段を提䟛する。芖芚的な画像のすぐ隣に音声のオプションを蚭眮する。これは圹立぀が、それでもサりンドカヌドのない人、芖聎芚障害者、䞀郚の制限された聎力をも぀人に察しお問題である。もう䞀぀の方法は、芖芚的な画像ずずもに質問フォヌムを含めるこずである。これは圹立぀が、認知障害を持぀人々に察しお問題ずなるかもしれない。

すべおのCAPTCHAの方匏は、障害をも぀ナヌザヌに察する入力ぞの容認できない障壁を導入するため、CAPTCHAの代替品を䜿甚するこずを匷く掚奚する。曎なる情報は、W3CのInaccessibility of CAPTCHAで利甚可胜である。

この䟋では、文字の歪んだ画像を䜿甚するCAPTCHAのテストを瀺す。alt属性でのテキストによる代替は、画像コンテンツにアクセスできない堎合にナヌザヌに察する手順を説明する。

captcha containing the words 'aides' and 'sprucest'. The letters are distorted and the color of the letters and background is partially inverted,

コヌド䟋:

<img src="captcha.png" alt="If you cannot view this image an audio challenge is provided."> 
  <!-- audio CAPTCHA option that allows the user to listen and type the word -->  
  <!-- form that asks a question -->
  
4.7.1.1.21 Guidance for markup generators

Markup generators (such as WYSIWYG authoring tools) should, wherever possible, obtain a text alternative from their users. However, it is recognized that in many cases, this will not be possible.

For images that are the sole contents of links, markup generators should examine the link target to determine the title of the target, or the URL of the target, and use information obtained in this manner as the text alternative.

For images that have captions, markup generators should use the figure and figcaption elements to provide the image's caption.

As a last resort, implementors should either set the alt attribute to the empty string, under the assumption that the image is a purely decorative image that doesn't add any information but is still specific to the surrounding content, or omit the alt attribute altogether, under the assumption that the image is a key part of the content.

Markup generators may specify a generator-unable-to-provide-required-alt attribute on img elements for which they have been unable to obtain a text alternative and for which they have therefore omitted the alt attribute. The value of this attribute must be the empty string. Documents containing such attributes are not conforming, but conformance checkers will silently ignore this error.

This is intended to avoid markup generators from being pressured into replacing the error of omitting the alt attribute with the even more egregious error of providing phony text alternatives, because state-of-the-art automated conformance checkers cannot distinguish phony text alternatives from correct text alternatives.

Markup generators should generally avoid using the image's own file name as the text alternative. Similarly, markup generators should avoid generating text alternatives from any content that will be equally available to presentation user agents (e.g. Web browsers).

This is because once a page is generated, it will typically not be updated, whereas the browsers that later read the page can be updated by the user, therefore the browser is likely to have more up-to-date and finely-tuned heuristics than the markup generator did when generating the page.

4.7.1.1.22 Guidance for conformance checkers

A conformance checker must report the lack of an alt attribute as an error unless one of the conditions listed below applies:

4.7.2 iframe芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
゚ンベディッドコンテンツ。
むンタラクティブコンテンツ。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
゚ンベディッドコンテンツが期埅される堎所。
コンテンツモデル
文で䞎えられる芁件に適合しおいるテキスト。
コンテンツ属性
グロヌバル属性
src - リ゜ヌスのアドレス
srcdoc - iframe内で描画する文曞
name - ネストされたブラりゞングコンテキスト名
sandbox - ネストされたコンテンツのセキュリティヌルヌル
width - 暪の次元
height - 瞊の次元
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
application、document、imgたたはpresentation。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLIFrameElement : HTMLElement {
           attribute DOMString src;
           attribute DOMString srcdoc;
           attribute DOMString name;
  [PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
           attribute DOMString width;
           attribute DOMString height;
  readonly attribute Document? contentDocument;
  readonly attribute WindowProxy? contentWindow;
};

iframe芁玠は、ネストされたブラりゞングコンテキストを衚す。

src属性は、ネストされたブラりゞングコンテキストが含むのに適圓なペヌゞのアドレスを䞎える。属性が存圚する堎合、朜圚的にスペヌスで囲たれた劥圓な空でないURLでなければならない。

srcdoc属性は、ネストされたブラりゞングコンテキストが含むのに適圓なペヌゞのコンテンツを提䟛する。属性の倀は、iframe srcdoc文曞の゜ヌスである。

属性が存圚する堎合、HTML文曞内のiframe芁玠は、指定された順序で、srcdocが存圚するならば、次の構文䞊のコンポヌネントを構成するHTML構文を䜿甚した倀を持たなければならない。

  1. 任意の数のコメントおよび空癜文字。
  2. 任意で、DOCTYPE。
  3. 任意の数のコメントおよび空癜文字。
  4. html芁玠の圢匏で、ルヌト芁玠。
  5. 任意の数のコメントおよび空癜文字。

XML文曞内のiframe芁玠のために、srcdoc属性が存圚する堎合、XML仕様でラベル付きdocument生成物に䞀臎する倀を持たなければならない。[XML]

HTML構文においお、著者は属性の内容を包むために"""U+0022文字を䜿甚するこずを単に芚えおおく必芁があり、それからすべお"""U+0022およびU+0026 AMPERSAND&文字を゚スケヌプし、およびsandbox属性を指定し、コンテンツの安党な埋め蟌みを確実にする必芁がある。

XHTML構文の制玄のために、XMLの"<"U+003C文字も同様に゚スケヌプする必芁がある。属性倀正芏化を防ぐために、䞀郚のXMLの空癜文字―具䜓的には"tab"U+0009、"LF"U+000D、"CR"U+000A―もたた゚スケヌプする必芁がある。[XML]

src属性ずsrcdoc属性が䞡方ずもに指定される堎合、srcdoc属性が優先される。これは、著者にsrcdoc属性をサポヌトしないレガシヌナヌザヌ゚ヌゞェントに察しおフォヌルバックURLを提䟛できる。


When an iframe element is inserted into a document, the user agent must create a nested browsing context, and then process the iframe attributes for the "first time".

When an iframe element is removed from a document, the user agent must discard the nested browsing context.

This happens without any unload events firing (the nested browsing context and its Document are discarded, not unloaded).

Whenever an iframe element with a nested browsing context has its srcdoc attribute set, changed, or removed, the user agent must process the iframe attributes.

Similarly, whenever an iframe element with a nested browsing context but with no srcdoc attribute specified has its src attribute set, changed, or removed, the user agent must process the iframe attributes.

When the user agent is to process the iframe attributes, it must run the first appropriate steps from the following list:

If the srcdoc attribute is specified

Navigate the element's child browsing context to a resource whose Content-Type is text/html, whose URL is about:srcdoc, and whose data consists of the value of the attribute. The resulting Document must be considered an iframe srcdoc document.

Otherwise, if the element has no src attribute specified, and the user agent is processing the iframe's attributes for the "first time"

Queue a task to run the iframe load event steps.

The task source for this task is the DOM manipulation task source.

そうでなければ
  1. If the value of the src attribute is missing, or its value is the empty string, let url be the string "about:blank".

    Otherwise, resolve the value of the src attribute, relative to the iframe element.

    If that is not successful, then let url be the string "about:blank". Otherwise, let url be the resulting absolute URL.

  2. If there exists an ancestor browsing context whose active document's address, ignoring fragment identifiers, is equal to url, then abort these steps.

  3. Navigate the element's child browsing context to url.

Any navigation required of the user agent in the process the iframe attributes algorithm must be completed as an explicit self-navigation override and with the iframe element's document's browsing context as the source browsing context.

Furthermore, if the active document of the element's child browsing context before such a navigation was not completely loaded at the time of the new navigation, then the navigation must be completed with replacement enabled.

Similarly, if the child browsing context's session history contained only one Document when the process the iframe attributes algorithm was invoked, and that was the about:blank Document created when the child browsing context was created, then any navigation required of the user agent in that algorithm must be completed with replacement enabled.

When a Document in an iframe is marked as completely loaded, the user agent must synchronously run the iframe load event steps.

A load event is also fired at the iframe element when it is created if no other data is loaded in it.

Each Document has an iframe load in progress flag and a mute iframe load flag. When a Document is created, these flags must be unset for that Document.

The iframe load event steps are as follows:

  1. Let child document be the active document of the iframe element's nested browsing context.

  2. If child document has its mute iframe load flag set, abort these steps.

  3. Set child document's iframe load in progress flag.

  4. Fire a simple event named load at the iframe element.

  5. Unset child document's iframe load in progress flag.

This, in conjunction with scripting, can be used to probe the URL space of the local network's HTTP servers. User agents may implement cross-origin access control policies that are stricter than those described above to mitigate this attack, but unfortunately such policies are typically not compatible with existing Web content.

When the iframe's browsing context's active document is not ready for post-load tasks, and when anything in the iframe is delaying the load event of the iframe's browsing context's active document, and when the iframe's browsing context is in the delaying load events mode, the iframe must delay the load event of its document.

If, during the handling of the load event, the browsing context in the iframe is again navigated, that will further delay the load event.

芁玠が䜜成される際、srcdoc属性が蚭定されず、src属性が蚭定されおない、たたは蚭定されるがその倀が解決できないのいずれかの堎合、ブラりゞングコンテキストは初期のabout:blankペヌゞのたたになる。

ナヌザヌがこのペヌゞから移動する堎合、iframeの察応WindowProxyオブゞェクトは、新芏Documentオブゞェクトに察する新芏Windowオブゞェクトをプロキシサヌバヌに送るが、src属性は倉曎されないだろう。


name属性が存圚する堎合、劥圓なブラりゞングコンテキスト名でなければならない。指定された倀は、ネストされたブラりゞングコンテキストに名前を付けるために䜿甚される。When the browsing context is created, if the attribute is present, the browsing context name must be set to the value of this attribute; otherwise, the browsing context name must be set to the empty string.

Whenever the name attribute is set, the nested browsing context's name must be changed to the new value. If the attribute is removed, the browsing context name must be set to the empty string.


sandbox属性が指定された堎合、iframeによっおホストされるあらゆるコンテンツに䞀連の远加の制限が可胜になる。その倀は、ASCII倧文字・小文字䞍区別である順䞍同なナニヌクなスペヌス区切りのトヌクンのセットでなければならない。蚱容される倀は、allow-forms、allow-pointer-lock、allow-popups、allow-same-origin、allow-scripts、allow-top-navigationである。

この属性が蚭定される堎合、コンテンツは䞀意な生成元からのものずしお扱われ、フォヌムやスクリプトは無効ずなり、リンクは他のブラりゞングコンテキストをタヌゲットするこずを防ぎ、プラグむンは保護される。allow-same-originキヌワヌドは、コンテンツにナニヌクな生成元を匷制する代わりに、コンテンツを実際の生成元からのものずしお扱わさせる。allow-top-navigationキヌワヌドは、コンテンツにトップレベルのブラりゞングコンテキストをナビゲヌトするこずができる。allow-forms、allow-pointer-lock、allow-popupsおよびallow-scriptsキヌワヌドは、フォヌム、ポむンタロックAPI、ポップアップ、およびスクリプトそれぞれを再有効にする。[POINTERLOCK]

効果的に完党にサンドボックスを砎壊する、iframeを含むペヌゞが埋め蟌たれたペヌゞに簡単にsandbox属性を削陀しお再読み蟌みできるので、埋め蟌たれたペヌゞが同䞀生成元を持぀際に、allow-scriptsおよびallow-same-originの䞡方のキヌワヌドを共に蚭定する。

iframeのネストされたブラりゞングコンテキストがナビゲヌトされる際、これらのフラグは効果のみを取る。それらを削陀する、たたは党䜓のsandbox属性を削陀するこずは、すでに読み蟌たれたペヌゞに圱響を䞎えない。

朜圚的に敵察的なファむルは、iframe芁玠を含むファむルず同じサヌバヌから提䟛されるべきではない。攻撃者がiframe内よりむしろ、盎接敵察コンテンツを単に蚪問するこずをナヌザヌに玍埗させるこずができる堎合、敵察コンテンツをサンドボックス化するこずは、最小限の助けずなる。敵察的なHTMLコンテンツが原因で発生する可胜性のある損害を制限するために、それは独立した専甚ドメむンから提䟛されるべきである。たずえsandbox属性の保護なしで、ナヌザヌが盎接そのペヌゞを蚪れるようだたす堎合でも、別のドメむンを䜿甚するこずは、ファむル内のスクリプトがサむトを攻撃できないこずを保蚌する。

When an iframe element with a sandbox attribute has its nested browsing context created (before the initial about:blank Document is created), and when an iframe element's sandbox attribute is set or changed while it has a nested browsing context, the user agent must parse the sandboxing directive using the attribute's value as the input, and the iframe element's nested browsing context's iframe sandboxing flag set as the output.

When an iframe element's sandbox attribute is removed while it has a nested browsing context, the user agent must empty the iframe element's nested browsing context's iframe sandboxing flag set as the output.

この䟋においお、䞀郚の完党に未知で、朜圚的に敵察的な、ナヌザヌが提䟛するHTMLコンテンツは、ペヌゞに埋め蟌たれおいる。コンテンツが別のドメむンから配信されおいるため、コンテンツはすべお通垞のクロスサむト制限の圱響を受ける。たた、埋め蟌みペヌゞはスクリプティング、プラグむン、フォヌムを無効にし、コンテンツは、任意のフレヌムやそのものたたは任意のフレヌム、たたはりィンドり自身が埋め蟌み以倖のりィンドりを移動できない。

<p>We're not scared of you! Here is your content, unedited:</p>
<iframe sandbox src="http://usercontent.example.net/getusercontent.cgi?id=12193"></iframe>

攻撃者が盎接そのペヌゞぞナヌザヌにアクセスするように玍埗させる堎合、ペヌゞがペヌゞ内で怜出された攻撃に被害を受け易くなるであろうサむトの生成元のコンテキストで実行されないように別のドメむンを䜿甚するこずが重芁である。

この䟋においお、別のサむトからガゞェットが埋め蟌たれおいる。ガゞェットは、スクリプトやフォヌムが有効であり、生成元サンドボックスの制限は解陀され、その発信元のサヌバヌず通信できる。しかし、プラグむンおよびポップアップを無効にしたように、サンドボックスは䟝然ずしお有甚であり、したがっおマルりェアやその他の脅嚁に晒されるナヌザヌのリスクを軜枛する。

<iframe sandbox="allow-same-origin allow-forms allow-scripts"
        src="http://maps.example.com/embedded.html"></iframe>

ファむルAに含たれる次の断片を仮定する

<iframe sandbox="allow-same-origin allow-forms" src=B></iframe>

たたファむルBに含たれるiframeを仮定する

<iframe sandbox="allow-scripts" src=C></iframe>

さらに、ファむルCに含たれるリンクを仮定する

<a href=D>Link</a>

この䟋に察しお、すべおのファむルがtext/htmlずしお䟛絊されるず仮定する。

このシナリオでは、ペヌゞCはすべおのサンドボックスのフラグを蚭定される。Aでiframeが無効であり、これがBにおいおiframeで蚭定されるallow-scriptsキヌワヌドセットを䞊曞きするので、スクリプトは無効である。フォヌムのiframeで蚭定できるように、スクリプトキヌワヌドを䞊曞きするためのスクリプトは、無効になっおいる。Bにおける内偎のiframeは、allow-formsキヌワヌドセットを蚭定されないため、フォヌムもたた無効である。

Suppose now that a script in A removes all the sandbox attributes in A and B. This would change nothing immediately. ナヌザヌがCのリンクをクリックした堎合、BでのiframeにペヌゞDを読み蟌み、リンクはペヌゞBが読み蟌たれた際にAの<c11><a12>iframe</a12></c11>内のネストされたブラりゞングコンテキストの状態だったため、あたかもBでのiframeがallow-same-originず<c8><a9>allow-forms</a9></c8>キヌワヌドが蚭定されおいたかのように、ペヌゞDは振る舞うだろう。

䜕が蚱可されお䜕が蚱可されないかに぀いお刀断するこずは非垞に困難であるため、䞀般に、動的に陀去したり、sandbox属性を倉曎したりするこずは賢明でない。


iframe芁玠は、埋め蟌たれたコンテンツが特定のサむズをも぀たずえば単䜍が明確に定矩された寞法をも぀堎合、寞法属性をサポヌトする。

指定した初期コンテンツ内容が正垞に䜿甚されるかどうかに関わらず、垞にネストしたブラりゞングコンテキストを䜜成するので、iframe芁玠はフォヌルバックコンテンツにならない。


iframe芁玠の子孫は䜕も衚さない。iframe芁玠をサポヌトしないレガシヌナヌザヌ゚ヌゞェントにおいお、コンテンツはフォヌルバックコンテンツずしお機胜するこずができるマヌクアップずしお解析される。

HTML文曞で䜿甚する堎合、iframe芁玠の蚱可されたコンテンツモデルはテキストである。ただし、context芁玠ずしおiframe芁玠およびinputずしおテキストコンテンツをも぀HTML断片解析アルゎリズムを呌び出すこずが、䞀切の解析゚ラヌなく、リスト内の任意の堎所にたたはリスト内の芁玠の子孫ずしおscript芁玠をもたず、か぀自身が適合するリストその子孫を含む内のすべおの芁玠をも぀、フレヌゞングコンテンツであるノヌドのリストをもたらさなければならないこずを陀く。

iframe芁玠は、XML文曞で空でなければならない。

HTMLパヌサは、テキストずしおiframe芁玠の内偎のマヌクアップを扱う。


The IDL attributes src, srcdoc, name, and sandbox must reflect the respective content attributes of the same name.

The contentDocument IDL attribute must return the Document object of the active document of the iframe element's nested browsing context, if any and if its effective script origin is the same origin as the effective script origin specified by the incumbent settings object, or null otherwise.

The contentWindow IDL attribute must return the WindowProxy object of the iframe element's nested browsing context, if any, or null otherwise.

広告ブロヌカヌから広告を含めるようにiframeを䜿ったペヌゞの䟋は次のずおり

<iframe src="http://ads.example.com/?customerid=923513721&amp;format=banner"
        width="468" height="60"></iframe>

4.7.3 embed芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
゚ンベディッドコンテンツ。
むンタラクティブコンテンツ。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
゚ンベディッドコンテンツが期埅される堎所。
コンテンツモデル
空。
コンテンツ属性
グロヌバル属性
src - リ゜ヌスのアドレス
type — 埋め蟌みリ゜ヌスタむプ
width - 暪の次元
height - 瞊の寞法
名前空間を持たないその他の属性文参照。
text/htmlにおけるタグ省略
終了タグなし
蚱可されるARIAロヌル属性倀
application、document、imgたたはpresentation。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLEmbedElement : HTMLElement {
           attribute DOMString src;
           attribute DOMString type;
           attribute DOMString width;
           attribute DOMString height;
  legacycaller any (any... arguments);
};

Depending on the type of content instantiated by the embed element, the node may also support other interfaces.

embed芁玠は倖郚の兞型的には非HTMLアプリケヌションやむンタラクティブコンテンツの統合点を提䟛する。

src属性は、埋め蟌たれおいるリ゜ヌスのアドレスを䞎える。属性が存圚する堎合、朜圚的にスペヌスで囲たれた劥圓な空でないURLを含たなければならない。

type属性が存圚する堎合は、むンスタンスを生成するプラグむンが遞択されるMIMEタむプを提䟛する。倀は劥圓なMIMEタむプでなければならない。type属性ずsrc属性の䞡方が存圚する堎合、type属性は、src属性で指定されたリ゜ヌスの明瀺的なContent-Typeメタデヌタず同じ型を指定しなければならない。

When the element is created with neither a src attribute nor a type attribute, and when attributes are removed such that neither attribute is present on the element anymore, and when the element has a media element ancestor, and when the element has an ancestor object element that is not showing its fallback content, any plugin instantiated for the element must be removed, and the embed element then represents nothing.

An embed element is said to be potentially active when the following conditions are all met simultaneously:

Whenever an embed element that was not potentially active becomes potentially active, and whenever a potentially active embed element that is remaining potentially active and has its src attribute set, changed, or removed or its type attribute set, changed, or removed, the user agent must queue a task using the embed task source to run the embed element setup steps.

The embed element setup steps are as follows:

  1. If another task has since been queued to run the embed element setup steps for this element, then abort these steps.

  2. If the element has a src attribute set

    The user agent must resolve the value of the element's src attribute, relative to the element. If that is successful, the user agent should fetch the resulting absolute URL, from the element's browsing context scope origin if it has one The task that is queued by the networking task source once the resource has been fetched must run the following steps:

    1. If another task has since been queued to run the embed element setup steps for this element, then abort these steps.

    2. Determine the type of the content being embedded, as follows (stopping at the first substep that determines the type):

      1. If the element has a type attribute, and that attribute's value is a type that a plugin supports, then the value of the type attribute is the content's type.

      2. Otherwise, if applying the URL parser algorithm to the URL of the specified resource (after any redirects) results in a parsed URL whose path component matches a pattern that a plugin supports, then the content's type is the type that that plugin can handle.

        For example, a plugin might say that it can handle resources with path components that end with the four character string ".swf".

      3. Otherwise, if the specified resource has explicit Content-Type metadata, then that is the content's type.

      4. Otherwise, the content has no type and there can be no appropriate plugin for it.

    3. If the previous step determined that the content's type is image/svg+xml, then run the following substeps:

      1. If the embed element is not associated with a nested browsing context, associate the element with a newly created nested browsing context, and, if the element has a name attribute, set the browsing context name of the element's nested browsing context to the value of this attribute.

      2. Navigate the nested browsing context to the fetched resource, with replacement enabled, and with the embed element's document's browsing context as the source browsing context. (The src attribute of the embed element doesn't get updated if the browsing context gets further navigated to other locations.)

      3. The embed element now represents its associated nested browsing context.

    4. Otherwise, find and instantiate an appropriate plugin based on the content's type, and hand that plugin the content of the resource, replacing any previously instantiated plugin for the element. The embed element now represents this plugin instance.

    Whether the resource is fetched successfully or not (e.g. whether the response code was a 2xx code or equivalent) must be ignored when determining the content's type and when handing the resource to the plugin.

    This allows servers to return data for plugins even with error responses (e.g. HTTP 500 Internal Server Error codes can still contain plugin data).

    Fetching the resource must delay the load event of the element's document.

    If the element has no src attribute set

    The user agent should find and instantiate an appropriate plugin based on the value of the type attribute. The embed element now represents this plugin instance.

The embed element has no fallback content. If the user agent can't find a suitable plugin when attempting to find and instantiate one for the algorithm above, then the user agent must use a default plugin. This default could be as simple as saying "Unsupported Format".

Whenever an embed element that was potentially active stops being potentially active, any plugin that had been instantiated for that element must be unloaded.

When a plugin is to be instantiated but it cannot be secured and the sandboxed plugins browsing context flag is set on the embed element's Document's active sandboxing flag set, then the user agent must not instantiate the plugin, and must instead render the embed element in a manner that conveys that the plugin was disabled. The user agent may offer the user the option to override the sandbox and instantiate the plugin anyway; if the user invokes such an option, the user agent must act as if the conditions above did not apply for the purposes of this element.

Plugins that cannot be secured are disabled in sandboxed browsing contexts because they might not honor the restrictions imposed by the sandbox (e.g. they might allow scripting even when scripting in the sandbox is disabled). User agents should convey the danger of overriding the sandbox to the user if an option to do so is provided.

Any namespace-less attribute other than name, align, hspace, and vspace may be specified on the embed element, so long as its name is XML-compatible and contains no uppercase ASCII letters. これらの属性は、プラグむンにパラメヌタずしお枡される。

倧文字の制限がそのような文曞に圱響しないので、HTML文曞内のすべおの属性は自動的に小文字を取埗する。

4぀の䟋倖は、プラグむンに送信するパラメヌタを超えた副䜜甚を持぀埓来の属性を陀倖するのに適圓である。

The user agent should pass the names and values of all the attributes of the embed element that have no namespace to the plugin used, when one is instantiated.

The HTMLEmbedElement object representing the element must expose the scriptable interface of the plugin instantiated for the embed element, if any. At a minimum, this interface must implement the legacy caller operation. (It is suggested that the default behavior of this legacy caller operation, e.g. the behavior of the default plugin's legacy caller operation, be to throw a NotSupportedError exception.)

embed芁玠は、寞法属性をサポヌトする。

The IDL attributes src and type each must reflect the respective content attributes of the same name.

これはFlashのような、独自のプラグむンを必芁ずするリ゜ヌスを埋め蟌むための方法である

<embed src="catgame.swf">

ナヌザヌがプラグむンを持たない堎合たずえばプラグむンベンダヌがナヌザヌのプラットフォヌムをサポヌトしない堎合、ナヌザヌはリ゜ヌスを䜿甚できない。

"high"倀をも぀パラメヌタ"quality"をプラグむンに枡すために、属性を指定できる

<embed src="catgame.swf" quality="high">

代わりにobject芁玠を䜿甚する堎合、次のものず等䟡になる

<object data="catgame.swf">
 <param name="quality" value="high">
</object>

4.7.4 object芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
゚ンベディッドコンテンツ。
芁玠がusemap属性をも぀堎合むンタラクティブコンテンツ。
リスト、送信可胜、再関連付け可胜 フォヌム関連芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
゚ンベディッドコンテンツが期埅される堎所。
コンテンツモデル
0個以䞊のparam芁玠、それから透過的。
コンテンツ属性
グロヌバル属性
data - リ゜ヌスのアドレス
type — 埋め蟌みリ゜ヌスタむプ
typemustmatch - type属性およびContent-Type倀が䜿甚されるリ゜ヌスにマッチする必芁があるかどうか
name - ネストされたブラりゞングコンテキスト名
usemap - 䜿甚するむメヌゞマップの名前
form - form芁玠ずコントロヌルを関連付ける
width - 暪の次元
height - 瞊の次元
text/htmlにおけるタグ省略
どちらのタグも省略䞍可。
蚱可されるARIAロヌル属性倀
application、document、imgたたはpresentation。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLObjectElement : HTMLElement {
           attribute DOMString data;
           attribute DOMString type;
           attribute boolean typeMustMatch;
           attribute DOMString name;
           attribute DOMString useMap;
  readonly attribute HTMLFormElement? form;
           attribute DOMString width;
           attribute DOMString height;
  readonly attribute Document? contentDocument;
  readonly attribute WindowProxy? contentWindow;

  readonly attribute boolean willValidate;
  readonly attribute ValidityState validity;
  readonly attribute DOMString validationMessage;
  boolean checkValidity();
  void setCustomValidity(DOMString error);

  legacycaller any (any... arguments);
};

Depending on the type of content instantiated by the object element, the node also supports other interfaces.

object芁玠は、リ゜ヌスの型に応じお、画像ずしお、ネストされたブラりゞングコンテキストずしお、たたはプラグむンによっお凊理される倖郚リ゜ヌスずしおのいずれかで扱われる、倖郚リ゜ヌスを衚すこずができる。

data属性は存圚する堎合、リ゜ヌスのアドレスを指定する。存圚する堎合、属性は、朜圚的にスペヌスで囲たれた劥圓な空でないURLでなければならない。

信頌しない他の生成元からリ゜ヌスを参照する著者は、䞋蚘に定矩されるtypemustmatch属性を䜿甚するよう促す。その属性がなければ、著者がFlashの"allowScriptAccess"パラメヌタなどの機胜を䜿甚した堎合であっおも、任意のスクリプトを実行するためにプラグむン機構を䜿甚するこずは、リモヌトホスト䞊の攻撃に察しお特定の堎合に可胜である。

type属性が存圚する堎合、リ゜ヌスのタむプを指定する。存圚する堎合、属性は劥圓なMIMEタむプでなければならない。

data属性たたはtype属性のいずれか䞀方が少なくずも存圚しなければならない。

typemustmatch属性は、type属性の倀ず、前述のリ゜ヌスのContent-Typeが䞀臎する堎合、その存圚がdata属性で指定されたリ゜ヌスにのみ䜿甚されるこずを瀺す真停属性である。

data属性ずtype属性の䞡方が存圚する堎合を陀き、typemustmatch属性を指定しおはならない。

name属性が存圚する堎合、劥圓なブラりゞングコンテキスト名でなければならない。該圓する堎合、䞎えられた倀は、ネストされたブラりゞングコンテキストに名前を付けるために䜿甚される。

Whenever one of the following conditions occur:

...the user agent must queue a task to run the following steps to (re)determine what the object element represents. The task source for this task is the DOM manipulation task source. This task being queued or actively running must delay the load event of the element's document.

  1. If the user has indicated a preference that this object element's fallback content be shown instead of the element's usual behavior, then jump to the step below labeled fallback.

    For example, a user could ask for the element's fallback content to be shown because that content uses a format that the user finds more accessible.

  2. If the element has an ancestor media element, or has an ancestor object element that is not showing its fallback content, or if the element is not in a Document with a browsing context, or if the element's Document is not fully active, or if the element is still in the stack of open elements of an HTML parser or XML parser, or if the element is not being rendered, then jump to the step below labeled fallback.

  3. If the classid attribute is present, and has a value that isn't the empty string, then: if the user agent can find a plugin suitable according to the value of the classid attribute, and either plugins aren't being sandboxed or that plugin can be secured, then that plugin should be used, and the value of the data attribute, if any, should be passed to the plugin. If no suitable plugin can be found, or if the plugin reports an error, jump to the step below labeled fallback.

  4. If the data attribute is present and its value is not the empty string, then:

    1. If the type attribute is present and its value is not a type that the user agent supports, and is not a type that the user agent can find a plugin for, then the user agent may jump to the step below labeled fallback without fetching the content to examine its real type.

    2. Resolve the URL specified by the data attribute, relative to the element.

    3. If that failed, fire a simple event named error at the element, then jump to the step below labeled fallback.

    4. Fetch the resulting absolute URL, from the element's browsing context scope origin if it has one

      Fetching the resource must delay the load event of the element's document until the task that is queued by the networking task source once the resource has been fetched (defined next) has been run.

      For the purposes of the application cache networking model, this fetch operation is not for a child browsing context (though it might end up being used for one after all, as defined below).

    5. If the resource is not yet available (e.g. because the resource was not available in the cache, so that loading the resource required making a request over the network), then jump to the step below labeled fallback. The task that is queued by the networking task source once the resource is available must restart this algorithm from this step. Resources can load incrementally; user agents may opt to consider a resource "available" whenever enough data has been obtained to begin processing the resource.

    6. If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), fire a simple event named error at the element, then jump to the step below labeled fallback.

    7. Determine the resource type, as follows:

      1. Let the resource type be unknown.

      2. If the object element has a type attribute and a typemustmatch attribute, and the resource has associated Content-Type metadata, and the type specified in the resource's Content-Type metadata is an ASCII case-insensitive match for the value of the element's type attribute, then let resource type be that type and jump to the step below labeled handler.

      3. If the object element has a typemustmatch attribute, jump to the step below labeled handler.

      4. If the user agent is configured to strictly obey Content-Type headers for this resource, and the resource has associated Content-Type metadata, then let the resource type be the type specified in the resource's Content-Type metadata, and jump to the step below labeled handler.

        This can introduce a vulnerability, wherein a site is trying to embed a resource that uses a particular plugin, but the remote site overrides that and instead furnishes the user agent with a resource that triggers a different plugin with different security characteristics.

      5. If there is a type attribute present on the object element, and that attribute's value is not a type that the user agent supports, but it is a type that a plugin supports, then let the resource type be the type specified in that type attribute, and jump to the step below labeled handler.

      6. Run the appropriate set of steps from the following list:

        If the resource has associated Content-Type metadata
        1. Let binary be false.

        2. If the type specified in the resource's Content-Type metadata is "text/plain", and the result of applying the rules for distinguishing if a resource is text or binary to the resource is that the resource is not text/plain, then set binary to true.

        3. If the type specified in the resource's Content-Type metadata is "application/octet-stream", then set binary to true.

        4. If binary is false, then let the resource type be the type specified in the resource's Content-Type metadata, and jump to the step below labeled handler.

        5. If there is a type attribute present on the object element, and its value is not application/octet-stream, then run the following steps:

          1. If the attribute's value is a type that a plugin supports, or the attribute's value is a type that starts with "image/" that is not also an XML MIME type, then let the resource type be the type specified in that type attribute.

          2. Jump to the step below labeled handler.

        Otherwise, if the resource does not have associated Content-Type metadata
        1. If there is a type attribute present on the object element, then let the tentative type be the type specified in that type attribute.

          Otherwise, let tentative type be the sniffed type of the resource.

        2. If tentative type is not application/octet-stream, then let resource type be tentative type and jump to the step below labeled handler.

      7. If applying the URL parser algorithm to the URL of the specified resource (after any redirects) results in a parsed URL whose path component matches a pattern that a plugin supports, then let resource type be the type that that plugin can handle.

        For example, a plugin might say that it can handle resources with path components that end with the four character string ".swf".

      It is possible for this step to finish, or for one of the substeps above to jump straight to the next step, with resource type still being unknown. In both cases, the next step will trigger fallback.

    8. Handler: Handle the content as given by the first of the following cases that matches:

      If the resource type is not a type that the user agent supports, but it is a type that a plugin supports

      If plugins are being sandboxed and the plugin that supports resource type cannot be secured, jump to the step below labeled fallback.

      Otherwise, the user agent should use the plugin that supports resource type and pass the content of the resource to that plugin. If the plugin reports an error, then jump to the step below labeled fallback.

      If the resource type is an XML MIME type, or if the resource type does not start with "image/"

      The object element must be associated with a newly created nested browsing context, if it does not already have one.

      If the URL of the given resource is not about:blank, the element's nested browsing context must then be navigated to that resource, with replacement enabled, and with the object element's document's browsing context as the source browsing context. (The data attribute of the object element doesn't get updated if the browsing context gets further navigated to other locations.)

      If the URL of the given resource is about:blank, then, instead, the user agent must queue a task to fire a simple event named load at the object element. No load event is fired at the about:blank document itself.

      The object element represents the nested browsing context.

      If the name attribute is present, the browsing context name must be set to the value of this attribute; otherwise, the browsing context name must be set to the empty string.

      In certain situations, e.g. if the resource was fetched from an application cache but it is an HTML file with a manifest attribute that points to a different application cache manifest, the navigation of the browsing context will be restarted so as to load the resource afresh from the network or a different application cache. Even if the resource is then found to have a different type, it is still used as part of a nested browsing context: only the navigate algorithm is restarted, not this object algorithm.

      If the resource type starts with "image/", and support for images has not been disabled

      Apply the image sniffing rules to determine the type of the image.

      The object element represents the specified image. The image is not a nested browsing context.

      If the image cannot be rendered, e.g. because it is malformed or in an unsupported format, jump to the step below labeled fallback.

      そうでなければ

      The given resource type is not supported. Jump to the step below labeled fallback.

      If the previous step ended with the resource type being unknown, this is the case that is triggered.

    9. The element's contents are not part of what the object element represents.

    10. Once the resource is completely loaded, queue a task to fire a simple event named load at the element.

      The task source for this task is the DOM manipulation task source.

  5. If the data attribute is absent but the type attribute is present, and the user agent can find a plugin suitable according to the value of the type attribute, and either plugins aren't being sandboxed or the plugin can be secured, then that plugin should be used. If these conditions cannot be met, or if the plugin reports an error, jump to the step below labeled fallback.

  6. Fallback: The object element represents the element's children, ignoring any leading param element children. This is the element's fallback content. If the element has an instantiated plugin, then unload it.

When the algorithm above instantiates a plugin, the user agent should pass to the plugin used the names and values of all the attributes on the element, in the order they were added to the element, with the attributes added by the parser being ordered in source order, followed by a parameter named "PARAM" whose value is null, followed by all the names and values of parameters given by param elements that are children of the object element, in tree order. If the plugin supports a scriptable interface, the HTMLObjectElement object representing the element should expose that interface. The object element represents the plugin. The plugin is not a nested browsing context.

Plugins are considered sandboxed for the purpose of an object element if the sandboxed plugins browsing context flag is set on the object element's Document's active sandboxing flag set.

Due to the algorithm above, the contents of object elements act as fallback content, used only when referenced resources can't be shown (e.g. because it returned a 404 error). This allows multiple object elements to be nested inside each other, targeting multiple user agents with different capabilities, with the user agent picking the first one it supports.

Whenever the name attribute is set, if the object element has a nested browsing context, its name must be changed to the new value. If the attribute is removed, if the object element has a browsing context, the browsing context name must be set to the empty string.

object芁玠が画像を衚すず同時に存圚する堎合、usemap属性は、むメヌゞマップに関連付けられるオブゞェクトを持぀こずを瀺すこずができる。The attribute must be ignored if the object element doesn't represent an image.

form属性は、明瀺的にそのフォヌムの所有者ずobject芁玠を関連付けるために䜿甚される。

Constraint validation: object elements are always barred from constraint validation.

object芁玠は寞法属性をサポヌトする。

The IDL attributes data, type and name each must reflect the respective content attributes of the same name. The typeMustMatch IDL attribute must reflect the typemustmatch content attribute. The useMap IDL attribute must reflect the usemap content attribute.

The contentDocument IDL attribute must return the Document object of the active document of the object element's nested browsing context, if any and if its effective script origin is the same origin as the effective script origin specified by the incumbent settings object, or null otherwise.

The contentWindow IDL attribute must return the WindowProxy object of the object element's nested browsing context, if it has one; otherwise, it must return null.

The willValidate, validity, and validationMessage attributes, and the checkValidity(), and setCustomValidity() methods, are part of the constraint validation API. The form IDL attribute is part of the element's forms API.

All object elements have a legacy caller operation. If the object element has an instantiated plugin that supports a scriptable interface that defines a legacy caller operation, then that must be the behavior of the object's legacy caller operation. Otherwise, the object's legacy caller operation must be to throw a NotSupportedError exception.

次の䟋においおJavaアプレットは、object芁玠を䜿甚しおペヌゞに埋め蟌たれおいる。䞀般的に蚀っお、アプリケヌションが、サヌドパヌティヌ補のプラグむンを必芁ずするこずなくすべおのりェブブラりザ䞊で動䜜するので、機胜を提䟛するためにネむティノのJavaScriptずHTMLを代わりに䜿甚するこずで、このようなアプレットの䜿甚を避けるこずがよりよい。特に組み蟌み機噚は、倚くのデバむスでJavaのようなサヌドパヌティのテクノロゞヌをサポヌトしない。

<figure>
 <object type="application/x-java-applet">
  <param name="code" value="MyJavaClass">
  <p>You do not have Java available, or it is disabled.</p>
 </object>
 <figcaption>My Java Clock</figcaption>
</figure>

この䟋においお、HTMLペヌゞはobject芁玠を䜿甚しお埋め蟌たれおいる。

<figure>
 <object data="clock.html"></object>
 <figcaption>My HTML Clock</figcaption>
</figure>

次の䟋は、プラグむンがこの堎合においおFlashプラグむンは、ビデオファむルを衚瀺するためにHTMLで䜿甚できる様子を瀺す。フォヌルバックは、Flashが有効でないナヌザヌに提䟛される。この堎合、video芁玠の䜿甚は、videoをサポヌトするナヌザヌ゚ヌゞェントを䜿甚するものに察しお動画を衚瀺し、最終的にFlashもvideoをサポヌトしないブラりザのどちらも持たない人に察するビデオぞのリンクを提䟛する。

<p>Look at my video:
 <object type="application/x-shockwave-flash">
  <param name=movie value="http://video.example.com/library/watch.swf">
  <param name=allowfullscreen value=true>
  <param name=flashvars value="http://video.example.com/vids/315981">
  <video controls src="http://video.example.com/vids/315981">
   <a href="http://video.example.com/vids/315981">View video</a>.
  </video>
 </object>
</p>

4.7.5 param芁玠

カテゎリ
なし。
この芁玠を䜿甚できるコンテキスト
任意のフロヌコンテンツの前の、object芁玠の子ずしお。
コンテンツモデル
空。
コンテンツ属性
グロヌバル属性
name - パラメヌタ名
value - パラメヌタ倀
text/htmlにおけるタグ省略
終了タグなし
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLParamElement : HTMLElement {
           attribute DOMString name;
           attribute DOMString value;
};

param芁玠は、object芁玠によっお呌び出されるプラグむンのパラメヌタを定矩する。この芁玠は、自分自身で䜕かを衚すものではない。

name属性は、パラメヌタの名前を䞎える。

value属性は、パラメヌタの倀を䞎える。

䞡方の属性が存圚しなければならない。これらは、任意の倀を持っおもよい。

If both attributes are present, and if the parent element of the param is an object element, then the element defines a parameter with the given name-value pair.

If either the name or value of a parameter defined by a param element that is the child of an object element that represents an instantiated plugin changes, and if that plugin is communicating with the user agent using an API that features the ability to update the plugin when the name or value of a parameter so changes, then the user agent must appropriately exercise that ability to notify the plugin of the change.

The IDL attributes name and value must both reflect the respective content attributes of the same name.

この堎合O3Dプラグむンにおいお、param芁玠が、プラグむンにパラメヌタを枡すために䜿甚する様子を次に瀺す。

<!DOCTYPE HTML>
<html lang="en">
  <head>
   <title>O3D Utah Teapot</title>
  </head>
  <body>
   <p>
    <object type="application/vnd.o3d.auto">
     <param name="o3d_features" value="FloatingPointTextures">
     <img src="o3d-teapot.png"
          title="3D Utah Teapot illustration rendered using O3D."
          alt="When O3D renders the Utah Teapot, it appears as a squat
          teapot with a shiny metallic finish on which the
          surroundings are reflected, with a faint shadow caused by
          the lighting.">
     <p>To see the teapot actually rendered by O3D on your
     computer, please download and install the <a
     href="http://code.google.com/apis/o3d/docs/gettingstarted.html#install">O3D plugin</a>.</p>
    </object>
    <script src="o3d-teapot.js"></script>
   </p>
  </body>
</html>

4.7.6 video芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
゚ンベディッドコンテンツ。
芁玠がcontrols属性を持぀堎合むンタラクティブコンテンツ。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
゚ンベディッドコンテンツが期埅される堎所。
コンテンツモデル
芁玠がsrc属性を持぀堎合0個以䞊のtrack芁玠で、次に透過的だが、media芁玠子孫をもたない。
芁玠がsrc属性を持たない堎合0個以䞊のsource芁玠で、次に0個以䞊のtrackで、次に透過的だが、media芁玠子孫をもたない。
コンテンツ属性
グロヌバル属性
src - リ゜ヌスのアドレス
crossorigin — 芁玠がcrossorigin芁求を凊理する方法
poster - 先にビデオプレむバックを芋せるポスタヌフレヌム
preload - メディアリ゜ヌスがどの皋床バッファリングに必芁になるかのヒント
autoplay - ペヌゞが読み蟌たれる際にメディアリ゜ヌスが自動的に開始可胜ずいうヒント
mediagroup - 暗黙のMediaControllerをも぀メディア芁玠グルヌプ
loop - メディアリ゜ヌスをルヌプするかどうか
muted - デフォルトでメディアリ゜ヌスをミュヌトするかどうか
controls - ナヌザヌ゚ヌゞェントのコントロヌルを衚瀺する
width - 暪の次元
height - 瞊の次元
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
application.
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLVideoElement : HTMLMediaElement {
           attribute unsigned long width;
           attribute unsigned long height;
  readonly attribute unsigned long videoWidth;
  readonly attribute unsigned long videoHeight;
           attribute DOMString poster;
};

video芁玠は字幕付きのビデオやムヌビヌ、オヌディオファむルを再生するために䜿甚される。

Content may be provided inside the video element. User agents should not show this content to the user; it is intended for older Web browsers which do not support video, so that legacy video plugins can be tried, or to show text to the users of these older browsers informing them of how to access the video contents.

特に、このコンテンツはアクセシビリティヌの懞念に察凊するためのものではない。匱芖、目の芋えない、難聎、耳が聞こえない、および他の身䜓たたは認知障害を持぀人々ぞのビデオコンテンツにアクセシブルにするための、さたざたな機胜が利甚可胜である。字幕は、ビデオストリヌムの埋め蟌みたたはtrack芁玠を䜿甚する倖郚ファむルずしおのいずれかを提䟛できる。手話トラックは、ビデオストリヌムの埋め蟌みたたはmediagroup属性たたはMediaControllerオブゞェクトを䜿甚する、耇数のvideo芁玠を同期させるこずのいずれかで提䟛できる。オヌディオの説明は、ビデオストリヌムに埋め蟌たれた個別のトラックずしお、video芁玠ずしお同じコントロヌラにスレヌブaudio芁玠での個別のオヌディオトラックずしお、たたはtrack芁玠を䜿甚しお参照され、か぀ナヌザヌ゚ヌゞェントによっお音声に合成されたWebVTTファむルを䜿甚するテキスト圢匏でのいずれかずしお提䟛できる。WebVTTはたた、章のタむトルを提䟛するために䜿甚できる。むしろ䞀切のメディア芁玠を䜿甚しないだろうナヌザヌの堎合、耇写物たたはその他のテキストの遞択肢は単にvideo芁玠の近くに文でそれらにリンクするこずによっお提䟛されうる。[WEBVTT]

video芁玠はmedia芁玠であり、そのメディアデヌタがおそらく関連する音声デヌタをも぀、衚面䞊は映像デヌタである。

src、preload、autoplay、mediagroup、loop、muted、およびcontrols属性は、すべおのメディア芁玠に共通の属性である。

poster属性はビデオデヌタが利甚可胜でない間に、ナヌザヌ゚ヌゞェントが衚瀺できる画像ファむルのアドレスを䞎える。属性が存圚する堎合、朜圚的にスペヌスで囲たれた劥圓な空でないURLを含たなければならない。

If the specified resource is to be used, then, when the element is created or when the poster attribute is set, changed, or removed, the user agent must run the following steps to determine the element's poster frame (regardless of the value of the element's show poster flag):

  1. If there is an existing instance of this algorithm running for this video element, abort that instance of this algorithm without changing the poster frame.

  2. If the poster attribute's value is the empty string or if the attribute is absent, then there is no poster frame; abort these steps.

  3. Resolve the poster attribute's value relative to the element. If this fails, then there is no poster frame; abort these steps.

  4. Fetch the resulting absolute URL, from the element's Document's origin. This must delay the load event of the element's document.

  5. If an image is thus obtained, the poster frame is that image. Otherwise, there is no poster frame.

poster属性によっお䞎えられた画像、poster frameは、ナヌザヌに映像がどのようなものであるかのテヌマを䞎える映像の代衚フレヌム通垞は最初の空癜でないフレヌムの1぀であるこずを意図する。


A video element represents what is given for the first matching condition in the list below:

When no video data is available (the element's readyState attribute is either HAVE_NOTHING, or HAVE_METADATA but no video data has yet been obtained at all, or the element's readyState attribute is any subsequent value but the media resource does not have a video channel)
The video element represents its poster frame, if any, or else transparent black with no intrinsic dimensions.
When the video element is paused, the current playback position is the first frame of video, and the element's show poster flag is set
The video element represents its poster frame, if any, or else the first frame of the video.
When the video element is paused, and the frame of video corresponding to the current playback position is not available (e.g. because the video is seeking or buffering)
When the video element is neither potentially playing nor paused (e.g. when seeking or stalled)
The video element represents the last frame of the video to have been rendered.
When the video element is paused
The video element represents the frame of video corresponding to the current playback position.
Otherwise (the video element has a video channel and is potentially playing)
The video element represents the frame of video at the continuously increasing "current" position. When the current playback position changes such that the last frame rendered is no longer the frame corresponding to the current playback position in the video, the new frame must be rendered.

Which frame in a video stream corresponds to a particular playback position is defined by the video stream's format.

The video element also represents any text track cues whose text track cue active flag is set and whose text track is in the showing mode, and any audio from the media resource, at the current playback position.

Any audio associated with the media resource must, if played, be played synchronized with the current playback position, at the element's effective media volume.

In addition to the above, the user agent may provide messages to the user (such as "buffering", "no video loaded", "error", or more detailed information) by overlaying text or icons on the video or other areas of the element's playback area, or in another appropriate manner.

User agents that cannot render the video may instead make the element represent a link to an external video playback utility or to the video data itself.

When a video element's media resource has a video channel, the element provides a paint source whose width is the media resource's intrinsic width, whose height is the media resource's intrinsic height, and whose appearance is the frame of video corresponding to the current playback position, if that is available, or else (e.g. when the video is seeking or buffering) its previous appearance, if any, or else (e.g. because the video is still loading the first frame) blackness.


video . videoWidth
video . videoHeight

これらの属性はビデオの内圚寞法を返し、寞法が未知の堎合に0を返す。

The intrinsic width and intrinsic height of the media resource are the dimensions of the resource in CSS pixels after taking into account the resource's dimensions, aspect ratio, clean aperture, resolution, and so forth, as defined for the format used by the resource. If an anamorphic format does not define how to apply the aspect ratio to the video data's dimensions to obtain the "correct" dimensions, then the user agent must apply the ratio by increasing one dimension and leaving the other unchanged.

The videoWidth IDL attribute must return the intrinsic width of the video in CSS pixels. The videoHeight IDL attribute must return the intrinsic height of the video in CSS pixels. If the element's readyState attribute is HAVE_NOTHING, then the attributes must return 0.

Whenever the intrinsic width or intrinsic height of the video changes (including, for example, because the selected video track was changed), if the element's readyState attribute is not HAVE_NOTHING, the user agent must queue a task to fire a simple event named resize at the media element.

video芁玠は、寞法属性をサポヌトする。

In the absence of style rules to the contrary, video content should be rendered inside the element's playback area such that the video content is shown centered in the playback area at the largest possible size that fits completely within it, with the video content's aspect ratio being preserved. Thus, if the aspect ratio of the playback area does not match the aspect ratio of the video, the video will be shown letterboxed or pillarboxed. Areas of the element's playback area that do not contain the video represent nothing.

In user agents that implement CSS, the above requirement can be implemented by using the style rule suggested in the rendering section.

The intrinsic width of a video element's playback area is the intrinsic width of the poster frame, if that is available and the element currently represents its poster frame; otherwise, it is the intrinsic width of the video resource, if that is available; otherwise the intrinsic width is missing.

The intrinsic height of a video element's playback area is the intrinsic height of the poster frame, if that is available and the element currently represents its poster frame; otherwise it is the intrinsic height of the video resource, if that is available; otherwise the intrinsic height is missing.

The default object size is a width of 300 CSS pixels and a height of 150 CSS pixels. [CSSIMAGES]


User agents should provide controls to enable or disable the display of closed captions, audio description tracks, and other additional data associated with the video stream, though such features should, again, not interfere with the page's normal rendering.

User agents may allow users to view the video content in manners more suitable to the user (e.g. full-screen or in an independent resizable window). As for the other user interface features, controls to enable this should not interfere with the page's normal rendering unless the user agent is exposing a user interface. In such an independent context, however, user agents may make full user interfaces visible, with, e.g., play, pause, seeking, and volume controls, even if the controls attribute is absent.

User agents may allow video playback to affect system features that could interfere with the user's experience; for example, user agents could disable screensavers while video playback is in progress.


The poster IDL attribute must reflect the poster content attribute.

この䟋は、ビデオを正垞に再生するために障害が発生したこずを怜出する様子を瀺す

<script>
 function failed(e) {
   // video playback failed - show a message saying why
   switch (e.target.error.code) {
     case e.target.error.MEDIA_ERR_ABORTED:
       alert('You aborted the video playback.');
       break;
     case e.target.error.MEDIA_ERR_NETWORK:
       alert('A network error caused the video download to fail part-way.');
       break;
     case e.target.error.MEDIA_ERR_DECODE:
       alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
       break;
     case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
       alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
       break;
     default:
       alert('An unknown error occurred.');
       break;
   }
 }
</script>
<p><video src="tgif.vid" autoplay controls onerror="failed(event)"></video></p>
<p><a href="tgif.vid">Download the video file</a>.</p>

4.7.7 audio芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
゚ンベディッドコンテンツ。
芁玠がcontrols属性を持぀堎合むンタラクティブコンテンツ。
芁玠がcontrols属性を持぀堎合パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
゚ンベディッドコンテンツが期埅される堎所。
コンテンツモデル
芁玠がsrc属性を持぀堎合0個以䞊のtrack芁玠で、次に透過的だが、media芁玠子孫をもたない。
芁玠がsrc属性を持たない堎合0個以䞊のsource芁玠で、次に0個以䞊のtrackで、次に透過的だが、media芁玠子孫をもたない。
コンテンツ属性
グロヌバル属性
src - リ゜ヌスのアドレス
crossorigin — 芁玠がcrossorigin芁求を凊理する方法
preload - メディアリ゜ヌスがどの皋床バッファリングに必芁になるかのヒント
autoplay - ペヌゞが読み蟌たれる際にメディアリ゜ヌスが自動的に開始可胜ずいうヒント
mediagroup - 暗黙のMediaControllerをも぀メディア芁玠グルヌプ
loop - メディアリ゜ヌスをルヌプするかどうか
muted - デフォルトでメディアリ゜ヌスをミュヌトするかどうか
controls - ナヌザヌ゚ヌゞェントのコントロヌルを衚瀺する
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
application.
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
[NamedConstructor=Audio(optional DOMString src)]
interface HTMLAudioElement : HTMLMediaElement {};

audio芁玠は、音やオヌディオのストリヌムを衚す。

Content may be provided inside the audio element. User agents should not show this content to the user; it is intended for older Web browsers which do not support audio, so that legacy audio plugins can be tried, or to show text to the users of these older browsers informing them of how to access the audio contents.

特に、このコンテンツはアクセシビリティヌの懞念に察凊するためのものではない。聎芚障害、たたは他の身䜓たたは認知障害を持぀人々ぞのオヌディオコンテンツにアクセシブルにするための、さたざたな機胜が利甚可胜である。字幕や手話の映像が䜿甚可胜な堎合、video芁玠は、ナヌザヌが芖芚的な遞択肢を有効にするこずができ、オヌディオを再生するaudio芁玠の代わりに䜿甚できる。章タむトルは、track芁玠ずWebVTTファむルを䜿甚しお、ナビゲヌションを補助するために提䟛できる。そしお圓然のこずながら、耇写物たたはその他のテキストの遞択肢は単にaudio芁玠の近くに文でそれらにリンクするこずによっお提䟛されうる。[WEBVTT]

audio芁玠は、メディアデヌタが衚面䞊は音声デヌタであるmedia芁玠である。

src、preload、autoplay、mediagroup、loop、muted、およびcontrols属性は、すべおのメディア芁玠に共通の属性である。

When an audio element is potentially playing, it must have its audio data played synchronized with the current playback position, at the element's effective media volume.

When an audio element is not potentially playing, audio must not play for the element.

audio = new Audio( [ url ] )

該圓する堎合、匕数で枡された倀に蚭定するsrc属性ずずもに、新しいaudio芁玠を返す。

A constructor is provided for creating HTMLAudioElement objects (in addition to the factory methods from DOM such as createElement()): Audio(src). When invoked as a constructor, it must return a new HTMLAudioElement object (a new audio element). The element must have its preload attribute set to the literal value "auto". If the src argument is present, the object created must have its src content attribute set to the provided value, and the user agent must invoke the object's resource selection algorithm before returning. The element's document must be the active document of the browsing context of the Window object on which the interface object of the invoked constructor is found.

4.7.8 source芁玠

カテゎリ
なし。
この芁玠を䜿甚できるコンテキスト
任意のフロヌコンテンツたたはtrack芁玠の前で、メディア芁玠の子ずしお。
コンテンツモデル
空。
コンテンツ属性
グロヌバル属性
src - リ゜ヌスのアドレス
type — 埋め蟌みリ゜ヌスタむプ
text/htmlにおけるタグ省略
終了タグなし
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLSourceElement : HTMLElement {
           attribute DOMString src;
           attribute DOMString type;
           attribute DOMString media;
};

source芁玠は、著者がメディア芁玠に察する耇数の代替メディアリ゜ヌスを指定できる。この芁玠は、自分自身で䜕かを衚すものではない。

src属性は、メディアリ゜ヌスのアドレスを䞎える。倀は、朜圚的にスペヌスで囲たれた劥圓な空でないURLでなければならない。この属性は存圚しなければならない。

芁玠がvideoやaudio芁玠にすでに挿入されおいる堎合、source芁玠ずその属性を動的に倉曎しおも効果はない。再生しおいる内容を倉曎するためには、䜿甚可胜なリ゜ヌスの䞭から遞択するcanPlayType()メ゜ッドをおそらく利甚しお、盎接メディア芁玠のsrc属性を単に䜿甚する。䞀般に、文曞が解析された埌に手動でsource芁玠を操䜜するこずは、䞍必芁に耇雑なアプロヌチずなる。

type属性は、この属性をフェッチする前に、このメディアリ゜ヌスを再生できるかどうかをナヌザヌ゚ヌゞェントが刀断するために、メディアリ゜ヌスの型を瀺す。指定された堎合、その倀は劥圓なMIMEタむプでなければならない。特定のMIMEタむプが定矩するコヌデックパラメヌタは、リ゜ヌスが゚ンコヌドされる方法を正確に指定する必芁があるかもしれない。[RFC6381]

次のリストは、type属性でcodecs=MIMEパラメヌタを䜿甚する方法の䟋を瀺す。

H.264制玄ベヌスラむンプロファむルビデオメむンおよび拡匵ビデオ互換性のあるレベル3ずMP4コンテナでのLow-Complexity AACオヌディオ
<source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
H.264拡匵プロファむルビデオベヌスラむン察応レベル3ずMP4コンテナでのLow-Complexity AACオヌディオ
<source src='video.mp4' type='video/mp4; codecs="avc1.58A01E, mp4a.40.2"'>
H.264メむンプロファむルビデオレベル3ずMP4コンテナのLow-Complexity AACオヌディオ
<source src='video.mp4' type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'>
H.264 'High'プロフィヌルビデオメむン、ベヌスラむン、たたは拡匵プロファむルず互換性がないレベル3ずMP4コンテナでのLow-Complexity AACオヌディオ
<source src='video.mp4' type='video/mp4; codecs="avc1.64001E, mp4a.40.2"'>
MPEG-4ビゞュアルのシンプルプロファむルレベル0ビデオずMP4コンテナのLow-Complexity AACオヌディオ
<source src='video.mp4' type='video/mp4; codecs="mp4v.20.8, mp4a.40.2"'>
MPEG-4アドバンストシンプルプロファむルレベル0ビデオずMP4コンテナのLow-Complexity AACオヌディオ
<source src='video.mp4' type='video/mp4; codecs="mp4v.20.240, mp4a.40.2"'>
MPEG-4映像シンプルプロファむルレベル0ビデオおよび3GPPコンテナ内AMRオヌディオ
<source src='video.3gp' type='video/3gpp; codecs="mp4v.20.8, samr"'>
TheoraビデオずOggコンテナでのVorbisオヌディオ
<source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'>
TheoraビデオずOggコンテナ内のSpeexオヌディオ
<source src='video.ogv' type='video/ogg; codecs="theora, speex"'>
OggコンテナでVorbisオヌディオ単独
<source src='audio.ogg' type='audio/ogg; codecs=vorbis'>
Oggコンテナ内のSpeexオヌディオ単独
<source src='audio.spx' type='audio/ogg; codecs=speex'>
Oggコンテナ内のFLACオヌディオ単独
<source src='audio.oga' type='audio/ogg; codecs=flac'>
DiracビデオずOggコンテナでのVorbisオヌディオ
<source src='video.ogv' type='video/ogg; codecs="dirac, vorbis"'>

属性をフェッチする前に、このメディアリ゜ヌスがナヌザヌにずっお有甚であるかどうかをナヌザヌ゚ヌゞェントが刀断するために、media属性は、メディアリ゜ヌスの意図されるメディアタむプを提䟛する。その倀は劥圓なメディアク゚リでなければならない。

リ゜ヌス遞択アルゎリズムは、media属性が省略される堎合、あたかも倀が"all"であるかのように、すなわち、デフォルトでメディアリ゜ヌスがすべおのメディアに適するようナヌザヌ゚ヌゞェントが同じように動䜜するような方法で定矩される。

If a source element is inserted as a child of a media element that has no src attribute and whose networkState has the value NETWORK_EMPTY, the user agent must invoke the media element's resource selection algorithm.

The IDL attributes src, type, and media must reflect the respective content attributes of the same name.

ナヌザヌ゚ヌゞェントがすべお提䟛されたメディアリ゜ヌスをレンダリングするこずができるかどうか、著者が確信できない堎合、著者は最埌のsource芁玠のフォヌルバック動䜜にerrorむベントを聎くこずができる

<script>
 function fallback(video) {
   // replace <video> with its contents
   while (video.hasChildNodes()) {
     if (video.firstChild instanceof HTMLSourceElement)
       video.removeChild(video.firstChild);
     else
       video.parentNode.insertBefore(video.firstChild, video);
   }
   video.parentNode.removeChild(video);
 }
</script>
<video controls autoplay>
 <source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
 <source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'
         onerror="fallback(parentNode)">
 ...
</video>

4.7.9 track芁玠

カテゎリ
なし。
この芁玠を䜿甚できるコンテキスト
任意のフロヌコンテンツの前の、メディア芁玠芁玠の子ずしお。
コンテンツモデル
空。
コンテンツ属性
グロヌバル属性
kind - テキストトラックの皮類
src - リ゜ヌスのアドレス
srclang - テキストトラックの蚀語
label - ナヌザヌ可芖ラベル
default - 他のテキストトラックがより適切でない堎合にトラックを䜜動させる
text/htmlにおけるタグ省略
終了タグなし
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLTrackElement : HTMLElement {
           attribute DOMString kind;
           attribute DOMString src;
           attribute DOMString srclang;
           attribute DOMString label;
           attribute boolean default;

  const unsigned short NONE = 0;
  const unsigned short LOADING = 1;
  const unsigned short LOADED = 2;
  const unsigned short ERROR = 3;
  readonly attribute unsigned short readyState;

  readonly attribute TextTrack track;
};

track芁玠は、著者がメディア芁玠に察しお明瀺的に倖郚調節されたテキストトラックを指定できる。この芁玠は、自分自身で䜕かを衚すものではない。

kind属性は、列挙属性である。以䞋の衚は、この属性に察しお定矩されたキヌワヌドを列挙する。各行の最初のセルに䞎えられるキヌワヌドは、2番目のセルで䞎えられる状態に察応する。

キヌワヌド 状態 抂芁
subtitles Subtitles 音声が利甚可胜な堎合に適するが、理解できないナヌザヌがメディアリ゜ヌスのオヌディオトラックの蚀語を理解しおいないためなど察話の翻字たたは翻蚳。ビデオにオヌバヌレむする。
captions Captions 音声が利甚できないか、はっきりず聞こえない堎合適したたずえば、無蚀である、呚囲の隒音によっおかき消される、たたはナヌザヌが聎芚障害者であるので、察話の翻字たたは翻蚳、音響効果、関連する音楜の合図、およびその他の関連オヌディオ情報。ビデオにオヌバヌレむし、難聎者に察しお適切に衚瀺される。
descriptions 抂芁 映像コンポヌネントが䞍明瞭、利甚できない、たたは䜿甚可胜でないたずえばナヌザヌが運転䞭に画面なしでアプリケヌションず情報をやりずりするため、たたはナヌザヌが盲目であるため際の音声合成に察しお意図される、メディアリ゜ヌスのビデオコンポヌネントのテキスト蚘述。オヌディオずしお合成される。
chapters Chapters メディアリ゜ヌスのナビゲヌトに䜿甚されるこずを意図した、章のタむトル。ナヌザヌ゚ヌゞェントのむンタヌフェヌス内のむンタラクティブな朜圚的に入れ子なリストずしお衚瀺される。
metadata Metadata トラックは、スクリプトから䜿甚するためのものである。ナヌザヌ゚ヌゞェントによっお衚瀺されない。

属性は省略しおもよい。欠損倀のデフォルトは、subtitles状態である。

src属性はテキストトラックデヌタのアドレスを䞎える。倀は、朜圚的にスペヌスで囲たれた劥圓な空でないURLでなければならない。この属性は存圚しなければならない。

If the element has a src attribute whose value is not the empty string and whose value, when the attribute was set, could be successfully resolved relative to the element, then the element's track URL is the resulting absolute URL. Otherwise, the element's track URL is the empty string.

芁玠のトラックURLがWebVTTリ゜ヌスを識別し、その芁玠のkind属性がメタデヌタ状態でない堎合、WebVTTファむルはキュヌテキストを䜿甚したWebVTTファむルでなければならない。[WEBVTT]

さらに、芁玠のトラックURLがWebVTTリ゜ヌスを識別し、その芁玠のkind属性がchapters状態である堎合、WebVTTファむルはキュヌテキストを䜿甚したWebVTTファむルずネストのみされたキュヌを䜿甚したWebVTTファむルの䞡方でなければならない。[WEBVTT]

srclang属性は、テキストトラックデヌタの蚀語を提䟛する。倀は、劥圓なBCP 47蚀語タグでなければならない。芁玠のkind属性が字幕状態である堎合、この属性は存圚しなければならない。[BCP47]

If the element has a srclang attribute whose value is not the empty string, then the element's track language is the value of the attribute. Otherwise, the element has no track language.

label属性は、トラックのナヌザヌが読めるタむトルを䞎える。それらのナヌザヌむンタヌフェヌスで字幕、キャプション、および音声解説トラックを䞀芧衚瀺する際に、このタむトルはナヌザヌ゚ヌゞェントによっお䜿甚される。

label属性の倀は属性が存圚する堎合、空文字列であっおはならない。たた、同じ状態にあるkind属性の同じメディア芁玠に属する2぀のtrack芁玠の子があっおはならず、そのsrclangは属性が欠萜しおいるか、同じ蚀語を衚す倀を持぀、およびそのlabel属性が再び䞡方欠萜するか、たたは䞡方同じ倀を持぀かの䞡方である。

If the element has a label attribute whose value is not the empty string, then the element's track label is the value of the attribute. Otherwise, the element's track label is an empty string.

default属性は真停属性であり、指定された堎合に、ナヌザヌの嗜奜が別のトラックがより適切であるこずを瀺さない堎合、トラックが有効にされるこずを瀺す。

各メディア芁玠は、kind属性がsubtitlesたたはcaptions状態か぀default属性が指定されるtrack芁玠の子を耇数個持っおはならない。

各メディア芁玠は、kind属性がdescription状態か぀default属性が指定されるtrack芁玠の子を耇数個持っおはならない。

各メディア芁玠は、kind属性がchapters状態か぀default属性が指定されるtrack芁玠の子を耇数個持っおはならない。

kind属性がmetadata状態か぀default属性が指定されるtrackの数に制限は存圚しない。

track . readyState

以䞋のリストから番号で衚されるテキストトラック準備状態を返す

track . NONE (0)

テキストトラックがロヌドされない状態。

track . LOADING (1)

テキストトラックがロヌドしおいる状態。

track . LOADED (2)

テキストトラックがロヌドされた状態。

track . ERROR (3)

テキストトラックがロヌドに倱敗した状態。

track . track

track芁玠のテキストトラックに察応するTextTrackオブゞェクトを返す。

The readyState attribute must return the numeric value corresponding to the text track readiness state of the track element's text track, as defined by the following list:

NONE (numeric value 0)
テキストトラックがロヌドされない状態。
LOADING (numeric value 1)
テキストトラックがロヌドしおいる状態。
LOADED (numeric value 2)
テキストトラックがロヌドされた状態。
ERROR (numeric value 3)
テキストトラックがロヌドに倱敗した状態。

The track IDL attribute must, on getting, return the track element's text track's corresponding TextTrack object.

The src, srclang, label, and default IDL attributes must reflect the respective content attributes of the same name. The kind IDL attribute must reflect the content attribute of the same name, limited to only known values.

このビデオは、耇数蚀語の字幕を持぀

<video src="brave.webm">
 <track kind=subtitles src=brave.en.vtt srclang=en label="English">
 <track kind=captions src=brave.en.hoh.vtt srclang=en label="English for the Hard of Hearing">
 <track kind=subtitles src=brave.fr.vtt srclang=fr lang=fr label="Français">
 <track kind=subtitles src=brave.de.vtt srclang=de lang=de label="Deutsch">
</video>

最埌の2぀のlang属性は、字幕自䜓の蚀語ではなく、label属性の蚀語を蚘述する。字幕の蚀語はsrclang属性によっお䞎えられる。

4.7.10 メディア芁玠

メディア芁玠この仕様ではaudioおよびvideoは次のむンタヌフェヌスを実装する

enum CanPlayTypeEnum { "" /* empty string */, "maybe", "probably" };
interface HTMLMediaElement : HTMLElement {

  // error state
  readonly attribute MediaError? error;

  // network state
           attribute DOMString src;
  readonly attribute DOMString currentSrc;
           attribute DOMString crossOrigin;
  const unsigned short NETWORK_EMPTY = 0;
  const unsigned short NETWORK_IDLE = 1;
  const unsigned short NETWORK_LOADING = 2;
  const unsigned short NETWORK_NO_SOURCE = 3;
  readonly attribute unsigned short networkState;
           attribute DOMString preload;
  readonly attribute TimeRanges buffered;
  void load();
  CanPlayTypeEnum canPlayType(DOMString type);

  // ready state
  const unsigned short HAVE_NOTHING = 0;
  const unsigned short HAVE_METADATA = 1;
  const unsigned short HAVE_CURRENT_DATA = 2;
  const unsigned short HAVE_FUTURE_DATA = 3;
  const unsigned short HAVE_ENOUGH_DATA = 4;
  readonly attribute unsigned short readyState;
  readonly attribute boolean seeking;

  // playback state
           attribute double currentTime;
  readonly attribute unrestricted double duration;
  Date getStartDate();
  readonly attribute boolean paused;
           attribute double defaultPlaybackRate;
           attribute double playbackRate;
  readonly attribute TimeRanges played;
  readonly attribute TimeRanges seekable;
  readonly attribute boolean ended;
           attribute boolean autoplay;
           attribute boolean loop;
  void play();
  void pause();

  // media controller
           attribute DOMString mediaGroup;
           attribute MediaController? controller;

  // controls
           attribute boolean controls;
           attribute double volume;
           attribute boolean muted;
           attribute boolean defaultMuted;

  // tracks
  readonly attribute AudioTrackList audioTracks;
  readonly attribute VideoTrackList videoTracks;
  readonly attribute TextTrackList textTracks;
  TextTrack addTextTrack(TextTrackKind kind, optional DOMString label = "", optional DOMString language = "");
};

メディア芁玠の属性、src、crossorigin、preload、autoplay、mediagroup、loop、muted、およびcontrolsは、すべおのメディア芁玠に適甚する。これらは、この節で定矩される。

メディア芁玠は、音声デヌタ、たたは映像ず音声のデヌタをナヌザヌに瀺すために䜿甚される。この節は音声や映像に察するメディア芁玠にも同様に適甚されるので、これは、この節においおメディアデヌタず芋なされる。甚語メディアリ゜ヌスは、たずえば完党なビデオファむル、たたは完党なオヌディオファむルなど、メディアデヌタの完党な集合を参照するために䜿甚される。

メディアリ゜ヌスは、耇数のオヌディオおよびビデオトラックを持぀こずができる。メディア芁玠の目的に察しお、メディアリ゜ヌスの映像デヌタは、芁玠のvideoTracks属性でもしあれば䞎えられる珟圚遞択されるトラックのみであり、たたメディアリ゜ヌスの音声デヌタは、もしあれば芁玠のaudioTracks属性によっお䞎えられるすべおの珟圚の有効なトラックは、混合の結果である。

audioずvideoの䞡方の芁玠は、オヌディオずビデオの䞡方に䜿甚できる。2぀の間の䞻な違いは、video芁玠が持぀のに察しお、audio芁玠は、芖芚コンテンツビデオやキャプションなどに察する再生領域を持たないこずだけである。

Except where otherwise explicitly specified, the task source for all the tasks queued in this section and its subsections is the media element event task source of the media element in question.

4.7.10.1 ゚ラヌコヌド
media . error

芁玠の珟圚の゚ラヌ状態を衚すMediaErrorオブゞェクトを返す。

゚ラヌが無い堎合nullを返す。

All media elements have an associated error status, which records the last error the element encountered since its resource selection algorithm was last invoked. The error attribute, on getting, must return the MediaError object created for this last error, or null if there has not been an error.

interface MediaError {
  const unsigned short MEDIA_ERR_ABORTED = 1;
  const unsigned short MEDIA_ERR_NETWORK = 2;
  const unsigned short MEDIA_ERR_DECODE = 3;
  const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
  readonly attribute unsigned short code;
};
media . error . code

䞋蚘のリストから、珟圚の゚ラヌの゚ラヌコヌドを返す。

The code attribute of a MediaError object must return the code for the error, which must be one of the following:

MEDIA_ERR_ABORTED数倀1
メディアリ゜ヌスに察するフェッチプロセスが、ナヌザヌの芁求でナヌザヌ゚ヌゞェントによっお䞭止された。
MEDIA_ERR_NETWORK数倀2
リ゜ヌスが䜿甚可胜であるこずが確立された埌、䞀郚の説明のネットワヌク゚ラヌは、ナヌザヌ゚ヌゞェントにメディアリ゜ヌスのフェッチを停止させた。
MEDIA_ERR_DECODE数倀3
リ゜ヌスが䜿甚可胜であるこずが確立された埌に、メディアリ゜ヌスをデコヌドする間に説明の゚ラヌが発生した。
MEDIA_ERR_SRC_NOT_SUPPORTED数倀4
src属性で瀺されるメディアリ゜ヌスは適さなかった。
4.7.10.2 メディアリ゜ヌスの堎所

メディア芁玠のsrcコンテンツ属性は、衚瀺するメディアリ゜ヌスビデオ、オヌディオのアドレスを䞎える。属性が存圚する堎合、朜圚的にスペヌスで囲たれた劥圓な空でないURLを含たなければならない。

メディア芁玠䞊のcrossoriginコンテンツ属性は、CORS蚭定属性である。

If a src attribute of a media element is set or changed, the user agent must invoke the media element's media element load algorithm. (Removing the src attribute does not do this, even if there are source elements present.)

The src IDL attribute on media elements must reflect the content attribute of the same name.

The crossOrigin IDL attribute must reflect the crossorigin content attribute, limited to only known values.

media . currentSrc

珟圚のメディアリ゜ヌスのアドレスを返す。

メディアリ゜ヌスが存圚しない堎合空文字列を返す。

The currentSrc IDL attribute is initially the empty string. Its value is changed by the resource selection algorithm defined below.

メディアリ゜ヌス、src属性、たたはsource芁玠を指定する2぀の方法がある。属性は芁玠を䞊曞きする。

4.7.10.3 MIMEタむプ

メディアリ゜ヌスは、codecパラメヌタをも぀䞀郚の堎合においお、そのタむプ、具䜓的にはMIMEタむプの芳点から説明できる。codecパラメヌタが蚱可されるたたはMIMEタむプに䟝存しないかどうかに関わらない[RFC6381]

タむプは、通垞倚少䞍完党な蚘述である。たずえば"video/mpeg"は、コンテナタむプが䜕であるかを陀いお䜕でも蚀わず、"video/mp4; codecs="avc1.42E01E, mp4a.40.2""のような型も実際のビットレヌト最倧ビットレヌトのみのような情報が含たれない。したがっお、タむプを指定されるナヌザヌ゚ヌゞェントは、信頌のレベルを倉化させたそのタむプのメディアを再生できるかもしれないかどうか、たたは間違いなくそのタむプのメディアを再生できないかどうかをたびたび知るこずができる。

ナヌザヌ゚ヌゞェントがレンダリングできないこずを認識するタむプは、たずえばコンテナの皮類を認識しない、たたは列挙されたコヌデックをサポヌトしないため、ナヌザヌ゚ヌゞェントは間違いなくサポヌトしないこずにリ゜ヌスを蚘述するものである。

パラメヌタのない"application/octet-stream" MIMEタむプは、ナヌザヌ゚ヌゞェントがレンダリングできないこずを認識するタむプにならない。朜圚的なメディアリ゜ヌスにラベルを付けるために䜿甚される際、ナヌザヌ゚ヌゞェントは、明瀺的なContent-Typeメタデヌタの欠劂ず同等ずしおそのタむプを扱わなければならない。

ここでパラメヌタなしのMIMEタむプ "application/octet-stream"は特殊な堎合である。任意のパラメヌタが型に出珟する堎合、その型は他のMIMEタむプず同じように扱われるだろう。This is a deviation from the rule that unknown MIME type parameters should be ignored.

media . canPlayType(type)

ナヌザヌ゚ヌゞェントはそれが䞎えられた型のメディアリ゜ヌスを再生できる"maybe"、たたは"probably"方法に基づいお空の文字列吊定応答を返す。

The canPlayType(type) method must return the empty string if type is a type that the user agent knows it cannot render or is the type "application/octet-stream"; it must return "probably" if the user agent is confident that the type represents a media resource that it can render if used in with this audio or video element; and it must return "maybe" otherwise. Implementors are encouraged to return "maybe" unless the type can be confidently established as being supported or not. Generally, a user agent should never return "probably" for a type that allows the codecs parameter if that parameter is not present.

このスクリプトは、ナヌザヌ゚ヌゞェントが動的にvideo芁玠たたはプラグむンを䜿甚するかどうかを決定する架空の新たなフォヌマットをサポヌトしおいるかどうかをテストする。

<section id="video">
 <p><a href="playing-cats.nfv">Download video</a></p>
</section>
<script>
 var videoSection = document.getElementById('video');
 var videoElement = document.createElement('video');
 var support = videoElement.canPlayType('video/x-new-fictional-format;codecs="kittens,bunnies"');
 if (support != "probably" && "New Fictional Video Plugin" in navigator.plugins) {
   // not confident of browser support
   // but we have a plugin
   // so use plugin instead
   videoElement = document.createElement("embed");
 } else if (support == "") {
   // no support from browser and no plugin
   // do nothing
   videoElement = null;
 }
 if (videoElement) {
   while (videoSection.hasChildNodes())
     videoSection.removeChild(videoSection.firstChild);
   videoElement.setAttribute("src", "playing-cats.nfv");
   videoSection.appendChild(videoElement);
 }
</script>

source芁玠のtype属性は、ナヌザヌ゚ヌゞェントがレンダリングできないフォヌマットを䜿甚するリ゜ヌスのダりンロヌドを回避できる。

4.7.10.4 ネットワヌク状態
media . networkState

䞋蚘のリストのコヌドから、芁玠に察するネットワヌク掻動の珟圚の状態を返す。

As media elements interact with the network, their current network activity is represented by the networkState attribute. On getting, it must return the current network state of the element, which must be one of the following values:

NETWORK_EMPTY数倀0
芁玠はただ初期化されおいない。すべおの属性は、初期状態である。
NETWORK_IDLE数倀1
The element's resource selection algorithm is active and has selected a resource, but it is not actually using the network at this time.
NETWORK_LOADING数倀2
ナヌザヌ゚ヌゞェントは、積極的にデヌタをダりンロヌドしようずしおいる。
NETWORK_NO_SOURCE数倀3
The element's resource selection algorithm is active, but it has not yet found a resource to use.

The resource selection algorithm defined below describes exactly when the networkState attribute changes value and what events fire to indicate changes in this state.

4.7.10.5 メディアリ゜ヌスの読み蟌み
media . load()

芁玠をリセットさせ、最初から新しいメディアリ゜ヌスの遞択ず読み蟌みを開始させる。

All media elements have an autoplaying flag, which must begin in the true state, and a delaying-the-load-event flag, which must begin in the false state. While the delaying-the-load-event flag is true, the element must delay the load event of its document.

When the load() method on a media element is invoked, the user agent must run the media element load algorithm.

The media element load algorithm consists of the following steps.

  1. Abort any already-running instance of the resource selection algorithm for this element.

  2. If there are any tasks from the media element's media element event task source in one of the task queues, then remove those tasks.

    If there are any tasks that were queued by the resource selection algorithm (including the algorithms that it itself invokes) for this same media element from the DOM manipulation task source in one of the task queues, then remove those tasks.

    Basically, pending events and callbacks for the media element are discarded when the media element starts loading a new resource.

  3. If the media element's networkState is set to NETWORK_LOADING or NETWORK_IDLE, queue a task to fire a simple event named abort at the media element.

  4. If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps:

    1. Queue a task to fire a simple event named emptied at the media element.

    2. If a fetching process is in progress for the media element, the user agent should stop it.

    3. Forget the media element's media-resource-specific tracks.

    4. If readyState is not set to HAVE_NOTHING, then set it to that state.

    5. If the paused attribute is false, then set it to true.

    6. If seeking is true, set it to false.

    7. Set the current playback position to 0.

      Set the official playback position to 0.

      If this changed the official playback position, then queue a task to fire a simple event named timeupdate at the media element.

    8. Set the initial playback position to 0.

    9. Set the timeline offset to Not-a-Number (NaN).

    10. Update the duration attribute to Not-a-Number (NaN).

      The user agent will not fire a durationchange event for this particular change of the duration.

  5. Set the playbackRate attribute to the value of the defaultPlaybackRate attribute.

  6. Set the error attribute to null and the autoplaying flag to true.

  7. Invoke the media element's resource selection algorithm.

  8. Playback of any previously playing media resource for this element stops.

The resource selection algorithm for a media element is as follows. This algorithm is always invoked synchronously, but one of the first steps in the algorithm is to return and continue running the remaining steps asynchronously, meaning that it runs in the background with scripts and other tasks running in parallel. In addition, this algorithm interacts closely with the event loop mechanism; in particular, it has synchronous sections (which are triggered as part of the event loop algorithm). Steps in such sections are marked with ⌛.

  1. Set the element's networkState attribute to the NETWORK_NO_SOURCE value.

  2. Set the element's show poster flag to true.

  3. Set the media element's delaying-the-load-event flag to true (this delays the load event).

  4. Asynchronously await a stable state, allowing the task that invoked this algorithm to continue. The synchronous section consists of all the remaining steps of this algorithm until the algorithm says the synchronous section has ended. (Steps in synchronous sections are marked with ⌛.)

  5. ⌛ If the media element's blocked-on-parser flag is false, then populate the list of pending text tracks.

  6. ⌛ If the media element has a src attribute, then let mode be attribute.

    ⌛ Otherwise, if the media element does not have a src attribute but has a source element child, then let mode be children and let candidate be the first such source element child in tree order.

    ⌛ Otherwise the media element has neither a src attribute nor a source element child: set the networkState to NETWORK_EMPTY, and abort these steps; the synchronous section ends.

  7. ⌛ Set the media element's networkState to NETWORK_LOADING.

  8. ⌛ Queue a task to fire a simple event named loadstart at the media element.

  9. If mode is attribute, then run these substeps:

    1. ⌛ If the src attribute's value is the empty string, then end the synchronous section, and jump down to the failed with attribute step below.

    2. ⌛ Let absolute URL be the absolute URL that would have resulted from resolving the URL specified by the src attribute's value relative to the media element when the src attribute was last changed.

    3. ⌛ If absolute URL was obtained successfully, set the currentSrc attribute to absolute URL.

    4. End the synchronous section, continuing the remaining steps asynchronously.

    5. If absolute URL was obtained successfully, run the resource fetch algorithm with absolute URL. If that algorithm returns without aborting this one, then the load failed.

    6. Failed with attribute: Reaching this step indicates that the media resource failed to load or that the given URL could not be resolved. Queue a task to run the following steps, using the DOM manipulation task source:

      1. Set the error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_SRC_NOT_SUPPORTED.

      2. Forget the media element's media-resource-specific tracks.

      3. Set the element's networkState attribute to the NETWORK_NO_SOURCE value.

      4. Set the element's show poster flag to true.

      5. Fire a simple event named error at the media element.

      6. Set the element's delaying-the-load-event flag to false. This stops delaying the load event.

    7. Wait for the task queued by the previous step to have executed.

    8. Abort these steps. Until the load() method is invoked or the src attribute is changed, the element won't attempt to load another resource.

    Otherwise, the source elements will be used; run these substeps:

    1. ⌛ Let pointer be a position defined by two adjacent nodes in the media element's child list, treating the start of the list (before the first child in the list, if any) and end of the list (after the last child in the list, if any) as nodes in their own right. One node is the node before pointer, and the other node is the node after pointer. Initially, let pointer be the position between the candidate node and the next node, if there are any, or the end of the list, if it is the last node.

      As nodes are inserted and removed into the media element, pointer must be updated as follows:

      If a new node is inserted between the two nodes that define pointer
      Let pointer be the point between the node before pointer and the new node. In other words, insertions at pointer go after pointer.
      If the node before pointer is removed
      Let pointer be the point between the node after pointer and the node before the node after pointer. In other words, pointer doesn't move relative to the remaining nodes.
      If the node after pointer is removed
      Let pointer be the point between the node before pointer and the node after the node before pointer. Just as with the previous case, pointer doesn't move relative to the remaining nodes.

      Other changes don't affect pointer.

    2. ⌛ Process candidate: If candidate does not have a src attribute, or if its src attribute's value is the empty string, then end the synchronous section, and jump down to the failed with elements step below.

    3. ⌛ Let absolute URL be the absolute URL that would have resulted from resolving the URL specified by candidate's src attribute's value relative to the candidate when the src attribute was last changed.

    4. ⌛ If absolute URL was not obtained successfully, then end the synchronous section, and jump down to the failed with elements step below.

    5. ⌛ If candidate has a type attribute whose value, when parsed as a MIME type (including any codecs described by the codecs parameter, for types that define that parameter), represents a type that the user agent knows it cannot render, then end the synchronous section, and jump down to the failed with elements step below.

    6. ⌛ If candidate has a media attribute whose value does not match the environment, then end the synchronous section, and jump down to the failed with elements step below.

    7. ⌛ Set the currentSrc attribute to absolute URL.

    8. End the synchronous section, continuing the remaining steps asynchronously.

    9. Run the resource fetch algorithm with absolute URL. If that algorithm returns without aborting this one, then the load failed.

    10. Failed with elements: Queue a task, using the DOM manipulation task source, to fire a simple event named error at the candidate element.

    11. Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorithm says the synchronous section has ended. (Steps in synchronous sections are marked with ⌛.)

    12. ⌛ Forget the media element's media-resource-specific tracks.

    13. ⌛ Find next candidate: Let candidate be null.

    14. ⌛ Search loop: If the node after pointer is the end of the list, then jump to the waiting step below.

    15. ⌛ If the node after pointer is a source element, let candidate be that element.

    16. ⌛ Advance pointer so that the node before pointer is now the node that was after pointer, and the node after pointer is the node after the node that used to be after pointer, if any.

    17. ⌛ If candidate is null, jump back to the search loop step. Otherwise, jump back to the process candidate step.

    18. ⌛ Waiting: Set the element's networkState attribute to the NETWORK_NO_SOURCE value.

    19. ⌛ Set the element's show poster flag to true.

    20. ⌛ Set the element's delaying-the-load-event flag to false. This stops delaying the load event.

    21. End the synchronous section, continuing the remaining steps asynchronously.

    22. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.)

    23. Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorithm says the synchronous section has ended. (Steps in synchronous sections are marked with ⌛.)

    24. ⌛ Set the element's delaying-the-load-event flag back to true (this delays the load event again, in case it hasn't been fired yet).

    25. ⌛ Set the networkState back to NETWORK_LOADING.

    26. ⌛ Jump back to the find next candidate step above.

The resource fetch algorithm for a media element and a given absolute URL is as follows:

  1. Let the current media resource be the resource given by the absolute URL passed to this algorithm. This is now the element's media resource.

  2. Remove all media-resource-specific text tracks from the media element's list of pending text tracks, if any.

  3. Optionally, run the following substeps. This is the expected behavior if the user agent intends to not attempt to fetch the resource until the user requests it explicitly (e.g. as a way to implement the preload attribute's none keyword).

    1. Set the networkState to NETWORK_IDLE.

    2. Queue a task to fire a simple event named suspend at the element, using the DOM manipulation task source.

    3. Set the element's delaying-the-load-event flag to false. This stops delaying the load event.

    4. Wait for the task to be run.

    5. Wait for an implementation-defined event (e.g. the user requesting that the media element begin playback).

    6. Set the element's delaying-the-load-event flag back to true (this delays the load event again, in case it hasn't been fired yet).

    7. Set the networkState to NETWORK_LOADING.

  4. Perform a potentially CORS-enabled fetch of the current media resource's absolute URL, with the mode being the state of the media element's crossorigin content attribute, the origin being the origin of the media element's Document, and the default origin behaviour set to taint.

    The resource obtained in this fashion, if any, contains the media data. It can be CORS-same-origin or CORS-cross-origin; this affects whether subtitles referenced in the media data are exposed in the API and, for video elements, whether a canvas gets tainted when the video is drawn on it.

    While the load is not suspended (see below), every 350ms (±200ms) or for every byte received, whichever is least frequent, queue a task to fire a simple event named progress at the element.

    The stall timeout is a user-agent defined length of time, which should be about three seconds. When a media element that is actively attempting to obtain media data has failed to receive any data for a duration equal to the stall timeout, the user agent must queue a task to fire a simple event named stalled at the element.

    User agents may allow users to selectively block or slow media data downloads. When a media element's download has been blocked altogether, the user agent must act as if it was stalled (as opposed to acting as if the connection was closed). The rate of the download may also be throttled automatically by the user agent, e.g. to balance the download with other connections sharing the same bandwidth.

    User agents may decide to not download more content at any time, e.g. after buffering five minutes of a one hour media resource, while waiting for the user to decide whether to play the resource or not, while waiting for user input in an interactive resource, or when the user navigates away from the page. When a media element's download has been suspended, the user agent must queue a task, using the DOM manipulation task source, to set the networkState to NETWORK_IDLE and fire a simple event named suspend at the element. If and when downloading of the resource resumes, the user agent must queue a task to set the networkState to NETWORK_LOADING. Between the queuing of these tasks, the load is suspended (so progress events don't fire, as described above).

    The preload attribute provides a hint regarding how much buffering the author thinks is advisable, even in the absence of the autoplay attribute.

    When a user agent decides to completely stall a download, e.g. if it is waiting until the user starts playback before downloading any further content, the element's delaying-the-load-event flag must be set to false. This stops delaying the load event.

    The user agent may use whatever means necessary to fetch the resource (within the constraints put forward by this and other specifications); for example, reconnecting to the server in the face of network errors, using HTTP range retrieval requests, or switching to a streaming protocol. The user agent must consider a resource erroneous only if it has given up trying to fetch it.

    This specification does not currently say whether or how to check the MIME types of the media resources, or whether or how to perform file type sniffing using the actual file data. Implementors differ in their intentions on this matter and it is therefore unclear what the right solution is. In the absence of any requirement here, the HTTP specification's strict requirement to follow the Content-Type header prevails ("Content-Type specifies the media type of the underlying data." ... "If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and./or the name extension(s) of the URI used to identify the resource.").

    The networking task source tasks to process the data as it is being fetched must, when appropriate, include the relevant substeps from the following list:

    If the media data cannot be fetched at all, due to network errors, causing the user agent to give up trying to fetch the resource
    If the media data can be fetched but is found by inspection to be in an unsupported format, or can otherwise not be rendered at all

    DNS errors, HTTP 4xx and 5xx errors (and equivalents in other protocols), and other fatal network errors that occur before the user agent has established whether the current media resource is usable, as well as the file using an unsupported container format, or using unsupported codecs for all the data, must cause the user agent to execute the following steps:

    1. The user agent should cancel the fetching process.

    2. Abort this subalgorithm, returning to the resource selection algorithm.

    If the media resource is found to have an audio track
    1. Create an AudioTrack object to represent the audio track.

    2. Update the media element's audioTracks attribute's AudioTrackList object with the new AudioTrack object.

    3. Fire a trusted event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent interface, with the track attribute initialized to the new AudioTrack object, at this AudioTrackList object.

    If the media resource is found to have a video track
    1. Create a VideoTrack object to represent the video track.

    2. Update the media element's videoTracks attribute's VideoTrackList object with the new VideoTrack object.

    3. Fire a trusted event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent interface, with the track attribute initialized to the new VideoTrack object, at this VideoTrackList object.

    Once enough of the media data has been fetched to determine the duration of the media resource, its dimensions, and other metadata

    This indicates that the resource is usable. The user agent must follow these substeps:

    1. Establish the media timeline for the purposes of the current playback position, the earliest possible position, and the initial playback position, based on the media data.

    2. Update the timeline offset to the date and time that corresponds to the zero time in the media timeline established in the previous step, if any. If no explicit time and date is given by the media resource, the timeline offset must be set to Not-a-Number (NaN).

    3. Set the current playback position and the official playback position to the earliest possible position.

    4. Update the duration attribute with the time of the last frame of the resource, if known, on the media timeline established above. If it is not known (e.g. a stream that is in principle infinite), update the duration attribute to the value positive Infinity.

      The user agent will queue a task to fire a simple event named durationchange at the element at this point.

    5. For video elements, set the videoWidth and videoHeight attributes, and queue a task to fire a simple event named resize at the media element.

      Further resize events will be fired if the dimensions subsequently change.

    6. Set the readyState attribute to HAVE_METADATA.

      A loadedmetadata DOM event will be fired as part of setting the readyState attribute to a new value.

    7. Let jumped be false.

    8. If the media element's default playback start position is greater than zero, then seek to that time, and let jumped be true.

    9. Let the media element's default playback start position be zero.

    10. If either the media resource or the address of the current media resource indicate a particular start time, then set the initial playback position to that time and, if jumped is still false, seek to that time and let jumped be true.

      For example, with media formats that support the Media Fragments URI fragment identifier syntax, the fragment identifier can be used to indicate a start position. [MEDIAFRAG]

    11. If either the media resource or the address of the current media resource indicate a particular set of audio or video tracks to enable, or if the user agent has information that would enable it to select specific tracks to improve the user's experience, then the relevant audio tracks must be enabled in the element's audioTracks object, and, of the relevant video tracks, the one that is listed first in the element's videoTracks object must be selected. All other tracks must be disabled.

      This could again be triggered by Media Fragments URI fragment identifier syntax, but it could also be triggered e.g. by the user agent selecting a 5.1 surround sound audio track over a stereo audio track. [MEDIAFRAG]

    12. If the media element has a current media controller, then: if jumped is true and the initial playback position, relative to the current media controller's timeline, is greater than the current media controller's media controller position, then seek the media controller to the media element's initial playback position, relative to the current media controller's timeline; otherwise, seek the media element to the media controller position, relative to the media element's timeline.

    Once the readyState attribute reaches HAVE_CURRENT_DATA, after the loadeddata event has been fired, set the element's delaying-the-load-event flag to false. This stops delaying the load event.

    A user agent that is attempting to reduce network usage while still fetching the metadata for each media resource would also stop buffering at this point, following the rules described previously, which involve the networkState attribute switching to the NETWORK_IDLE value and a suspend event firing.

    The user agent is required to determine the duration of the media resource and go through this step before playing.

    Once the entire media resource has been fetched (but potentially before any of it has been decoded)

    Fire a simple event named progress at the media element.

    Set the networkState to NETWORK_IDLE and fire a simple event named suspend at the media element.

    If the user agent ever discards any media data and then needs to resume the network activity to obtain it again, then it must queue a task to set the networkState to NETWORK_LOADING.

    If the user agent can keep the media resource loaded, then the algorithm will continue to its final step below, which aborts the algorithm.

    If the connection is interrupted after some media data has been received, causing the user agent to give up trying to fetch the resource

    Fatal network errors that occur after the user agent has established whether the current media resource is usable (i.e. once the media element's readyState attribute is no longer HAVE_NOTHING) must cause the user agent to execute the following steps:

    1. The user agent should cancel the fetching process.

    2. Set the error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_NETWORK.

    3. Fire a simple event named error at the media element.

    4. Set the element's networkState attribute to the NETWORK_IDLE value.

    5. Set the element's delaying-the-load-event flag to false. This stops delaying the load event.

    6. Abort the overall resource selection algorithm.

    If the media data is corrupted

    Fatal errors in decoding the media data that occur after the user agent has established whether the current media resource is usable must cause the user agent to execute the following steps:

    1. The user agent should cancel the fetching process.

    2. Set the error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_DECODE.

    3. Fire a simple event named error at the media element.

    4. If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the element's networkState attribute to the NETWORK_EMPTY value, set the element's show poster flag to true, and fire a simple event named emptied at the element.

      Otherwise, set the element's networkState attribute to the NETWORK_IDLE value.

    5. Set the element's delaying-the-load-event flag to false. This stops delaying the load event.

    6. Abort the overall resource selection algorithm.

    If the media data fetching process is aborted by the user

    The fetching process is aborted by the user, e.g. because the user pressed a "stop" button, the user agent must execute the following steps. These steps are not followed if the load() method itself is invoked while these steps are running, as the steps above handle that particular kind of abort.

    1. The user agent should cancel the fetching process.

    2. Set the error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_ABORTED.

    3. Fire a simple event named abort at the media element.

    4. If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the element's networkState attribute to the NETWORK_EMPTY value, set the element's show poster flag to true, and fire a simple event named emptied at the element.

      Otherwise, set the element's networkState attribute to the NETWORK_IDLE value.

    5. Set the element's delaying-the-load-event flag to false. This stops delaying the load event.

    6. Abort the overall resource selection algorithm.

    If the media data can be fetched but has non-fatal errors or uses, in part, codecs that are unsupported, preventing the user agent from rendering the content completely correctly but not preventing playback altogether

    The server returning data that is partially usable but cannot be optimally rendered must cause the user agent to render just the bits it can handle, and ignore the rest.

    If the media resource is found to declare a media-resource-specific text track that the user agent supports

    If the media data is CORS-same-origin, run the steps to expose a media-resource-specific text track with the relevant data.

    Cross-origin videos do not expose their subtitles, since that would allow attacks such as hostile sites reading subtitles from confidential videos on a user's intranet.

    When the networking task source has queued the last task as part of fetching the media resource (i.e. once the download has completed), if the fetching process completes without errors, including decoding the media data, and if all of the data is available to the user agent without network access, then, the user agent must move on to the next step. This might never happen, e.g. when streaming an infinite resource such as Web radio, or if the resource is longer than the user agent's ability to cache data.

    While the user agent might still need network access to obtain parts of the media resource, the user agent must remain on this step.

    For example, if the user agent has discarded the first half of a video, the user agent will remain at this step even once the playback has ended, because there is always the chance the user will seek back to the start. In fact, in this situation, once playback has ended, the user agent will end up firing a suspend event, as described earlier.

  5. If the user agent ever reaches this step (which can only happen if the entire resource gets loaded and kept available): abort the overall resource selection algorithm.

When a media element is to forget the media element's media-resource-specific tracks, the user agent must remove from the media element's list of text tracks all the media-resource-specific text tracks, then empty the media element's audioTracks attribute's AudioTrackList object, then empty the media element's videoTracks attribute's VideoTrackList object. No events (in particular, no removetrack events) are fired as part of this; the error and emptied events, fired by the algorithms that invoke this one, can be used instead.


preload属性は列挙属性である。次の衚は、キヌワヌドず属性の状態を瀺す。1列目のキヌワヌドは、キヌワヌドず同じ行で2列目のセル内の状態に察応づける。メディアリ゜ヌスがバッファたたは再生されおいる堎合でも属性を倉曎できる。䞋蚘の衚の説明では、この点に留意しお解釈されるべきである。

キヌワヌド 状態 抂芁
なし なし 著者がメディアリ゜ヌスを必芁ずするこずをナヌザヌに期埅しない、たたはサヌバヌが䞍芁なトラフィックを最小限にしたいのいずれかのナヌザヌ゚ヌゞェントぞのヒント。バッファリングはずにかく開始するたずえばナヌザヌが"play"に圓たる堎合、この状態は、メディアリ゜ヌスを実際にダりンロヌドする方法に関しお積極的にヒントを提䟛しない。
metadata Metadata 著者がメディアリ゜ヌスを必芁ずするずナヌザヌに期埅しないが、リ゜ヌスのメタデヌタ寞法、トラックリスト、期間などフェッチし、そしおおそらく最初の数フレヌムが合理的であるナヌザヌ゚ヌゞェントぞのヒント。ナヌザヌ゚ヌゞェントが正確にメタデヌタ以䞊のものをフェッチしない堎合、兞型的には、䞀郚のフレヌムも同様に埗られ、おそらくHAVE_CURRENT_DATAたたはHAVE_FUTURE_DATAになるにもかかわらず、メディア芁玠はHAVE_METADATAに蚭定されるreadyState属性に終わる。メディアリ゜ヌスが再生する際、たずえばメディアデヌタが䟝然ずしお䞀貫した再生を維持し最も遅い可胜性のレヌトで埗られるようにダりンロヌドを絞るこずが瀺唆するような、垯域幅の䞍足を考慮すべきであるずいうナヌザヌ゚ヌゞェントぞのヒント。
auto Automatic ナヌザヌ゚ヌゞェントが、楜芳的に党䜓のリ゜ヌスのダりンロヌドを含め、サヌバヌぞのリスクなしに、最初のナヌザヌのニヌズを眮くこずができるずいうナヌザヌ゚ヌゞェントぞのヒント。

空文字列もたた劥圓なキヌワヌドであり、自動状態に察応づける。メタデヌタ状態はサヌバヌの負荷を軜枛し、最適なナヌザヌ゚クスペリ゚ンスを提䟛する劥協点ずしお瀺唆されるけれども、属性の欠損デフォルト倀は、ナヌザヌ゚ヌゞェント定矩である。

䞀床ナヌザヌが再生を始めるず、著者は、動的に"none"たたは"metadata"から"auto"に属性を切り替えるかもしれない。たずえば、倚くのビデオをも぀ペヌゞ䞊で、芁求されないが䞀床に動画が積極的にダりンロヌドされる限り、これは倚くの動画がダりンロヌドされるべきではないこずを瀺すために䜿甚されるかもしれない。

The preload attribute is intended to provide a hint to the user agent about what the author thinks will lead to the best user experience. The attribute may be ignored altogether, for example based on explicit user preferences or based on the available connectivity.

The preload IDL attribute must reflect the content attribute of the same name, limited to only known values.

メディアを再生する堎合、preload属性によっお䞎えられるヒントにかかわらず、自然に最初のバッファを持぀のでautoplay属性はpreload属性を䞊曞きできる。しかし、䞡方を含めるこずぱラヌではない。


media . buffered

ナヌザヌ゚ヌゞェントがバッファリングしたメディアリ゜ヌスの範囲を衚すTimeRangesオブゞェクトを返す。

The buffered attribute must return a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent has buffered, at the time the attribute is evaluated. Users agents must accurately determine the ranges available, even for media streams where this can only be determined by tedious inspection.

Typically this will be a single range anchored at the zero point, but if, e.g. the user agent uses HTTP range requests in response to seeking, then there could be multiple ranges.

User agents may discard previously buffered data.

Thus, a time position included within a range of the objects return by the buffered attribute at one time can end up being not included in the range(s) of objects returned by the same attribute at later times.

4.7.10.6 メディアリ゜ヌスからのオフセット
media . duration

メディアリ゜ヌスの始点が時間れロであるず仮定しお、秒単䜍でメディアリ゜ヌスの長さを返す。

期間が利甚できない堎合はNaNを返す。

際限のないストリヌムに察しおInfinityを返す。

media . currentTime [ = value ]

秒単䜍で、公匏の再生䜍眮を返す。

指定時間にシヌクするために、蚭定可胜である。

遞択したメディアリ゜ヌスがない堎合、たたは珟圚のメディアコントロヌラがある堎合、InvalidStateError䟋倖を投げる。

A media resource has a media timeline that maps times (in seconds) to positions in the media resource. The origin of a timeline is its earliest defined position. The duration of a timeline is its last defined position.

Establishing the media timeline: If the media resource somehow specifies an explicit timeline whose origin is not negative (i.e. gives each frame a specific time offset and gives the first frame a zero or positive offset), then the media timeline should be that timeline. (Whether the media resource can specify a timeline or not depends on the media resource's format.) If the media resource specifies an explicit start time and date, then that time and date should be considered the zero point in the media timeline; the timeline offset will be the time and date, exposed using the getStartDate() method.

If the media resource has a discontinuous timeline, the user agent must extend the timeline used at the start of the resource across the entire resource, so that the media timeline of the media resource increases linearly starting from the earliest possible position (as defined below), even if the underlying media data has out-of-order or even overlapping time codes.

For example, if two clips have been concatenated into one video file, but the video format exposes the original times for the two clips, the video data might expose a timeline that goes, say, 00:15..00:29 and then 00:05..00:38. However, the user agent would not expose those times; it would instead expose the times as 00:15..00:29 and 00:29..01:02, as a single video.

In the rare case of a media resource that does not have an explicit timeline, the zero time on the media timeline should correspond to the first frame of the media resource. In the even rarer case of a media resource with no explicit timings of any kind, not even frame durations, the user agent must itself determine the time for each frame in a user-agent-defined manner. (This is a fingerprinting vector.)

An example of a file format with no explicit timeline but with explicit frame durations is the Animated GIF format. An example of a file format with no explicit timings at all is the JPEG-push format (multipart/x-mixed-replace with JPEG frames, often used as the format for MJPEG streams).

If, in the case of a resource with no timing information, the user agent will nonetheless be able to seek to an earlier point than the first frame originally provided by the server, then the zero time should correspond to the earliest seekable time of the media resource; otherwise, it should correspond to the first frame received from the server (the point in the media resource at which the user agent began receiving the stream).

At the time of writing, there is no known format that lacks explicit frame time offsets yet still supports seeking to a frame before the first frame sent by the server.

Consider a stream from a TV broadcaster, which begins streaming on a sunny Friday afternoon in October, and always sends connecting user agents the media data on the same media timeline, with its zero time set to the start of this stream. Months later, user agents connecting to this stream will find that the first frame they receive has a time with millions of seconds. The getStartDate() method would always return the date that the broadcast started; this would allow controllers to display real times in their scrubber (e.g. "2:30pm") rather than a time relative to when the broadcast began ("8 months, 4 hours, 12 minutes, and 23 seconds").

Consider a stream that carries a video with several concatenated fragments, broadcast by a server that does not allow user agents to request specific times but instead just streams the video data in a predetermined order, with the first frame delivered always being identified as the frame with time zero. If a user agent connects to this stream and receives fragments defined as covering timestamps 2010-03-20 23:15:00 UTC to 2010-03-21 00:05:00 UTC and 2010-02-12 14:25:00 UTC to 2010-02-12 14:35:00 UTC, it would expose this with a media timeline starting at 0s and extending to 3,600s (one hour). Assuming the streaming server disconnected at the end of the second clip, the duration attribute would then return 3,600. The getStartDate() method would return a Date object with a time corresponding to 2010-03-20 23:15:00 UTC. However, if a different user agent connected five minutes later, it would (presumably) receive fragments covering timestamps 2010-03-20 23:20:00 UTC to 2010-03-21 00:05:00 UTC and 2010-02-12 14:25:00 UTC to 2010-02-12 14:35:00 UTC, and would expose this with a media timeline starting at 0s and extending to 3,300s (fifty five minutes). In this case, the getStartDate() method would return a Date object with a time corresponding to 2010-03-20 23:20:00 UTC.

In both of these examples, the seekable attribute would give the ranges that the controller would want to actually display in its UI; typically, if the servers don't support seeking to arbitrary times, this would be the range of time from the moment the user agent connected to the stream up to the latest frame that the user agent has obtained; however, if the user agent starts discarding earlier information, the actual range might be shorter.

In any case, the user agent must ensure that the earliest possible position (as defined below) using the established media timeline, is greater than or equal to zero.

The media timeline also has an associated clock. Which clock is used is user-agent defined, and may be media resource-dependent, but it should approximate the user's wall clock.

All the media elements that share current media controller use the same clock for their media timeline.

Media elements have a current playback position, which must initially (i.e. in the absence of media data) be zero seconds. The current playback position is a time on the media timeline.

Media elements also have an official playback position, which must initially be set to zero seconds. The official playback position is an approximation of the current playback position that is kept stable while scripts are running.

Media elements also have a default playback start position, which must initially be set to zero seconds. This time is used to allow the element to be seeked even before the media is loaded.

Each media element has a show poster flag. When a media element is created, this flag must be set to true. This flag is used to control when the user agent is to show a poster frame for a video element instead of showing the video contents.

The currentTime attribute must, on getting, return the media element's default playback start position, unless that is zero, in which case it must return the element's official playback position. The returned value must be expressed in seconds. On setting, if the media element has a current media controller, then the user agent must throw an InvalidStateError exception; otherwise, if the media element's readyState is HAVE_NOTHING, then it must set the media element's default playback start position to the new value; otherwise, it must set the official playback position to the new value and then seek to the new value. The new value must be interpreted as being in seconds.

Media elements have an initial playback position, which must initially (i.e. in the absence of media data) be zero seconds. The initial playback position is updated when a media resource is loaded. The initial playback position is a time on the media timeline.

If the media resource is a streaming resource, then the user agent might be unable to obtain certain parts of the resource after it has expired from its buffer. Similarly, some media resources might have a media timeline that doesn't start at zero. The earliest possible position is the earliest position in the stream or resource that the user agent can ever obtain again. It is also a time on the media timeline.

The earliest possible position is not explicitly exposed in the API; it corresponds to the start time of the first range in the seekable attribute's TimeRanges object, if any, or the current playback position otherwise.

When the earliest possible position changes, then: if the current playback position is before the earliest possible position, the user agent must seek to the earliest possible position; otherwise, if the user agent has not fired a timeupdate event at the element in the past 15 to 250ms and is not still running event handlers for such an event, then the user agent must queue a task to fire a simple event named timeupdate at the element.

Because of the above requirement and the requirement in the resource fetch algorithm that kicks in when the metadata of the clip becomes known, the current playback position can never be less than the earliest possible position.

If at any time the user agent learns that an audio or video track has ended and all media data relating to that track corresponds to parts of the media timeline that are before the earliest possible position, the user agent may queue a task to first remove the track from the audioTracks attribute's AudioTrackList object or the videoTracks attribute's VideoTrackList object as appropriate and then fire a trusted event with the name removetrack, that does not bubble and is not cancelable, and that uses the TrackEvent interface, with the track attribute initialized to the AudioTrack or VideoTrack object representing the track, at the media element's aforementioned AudioTrackList or VideoTrackList object.

The duration attribute must return the time of the end of the media resource, in seconds, on the media timeline. If no media data is available, then the attributes must return the Not-a-Number (NaN) value. If the media resource is not known to be bounded (e.g. streaming radio, or a live event with no announced end time), then the attribute must return the positive Infinity value.

The user agent must determine the duration of the media resource before playing any part of the media data and before setting readyState to a value equal to or greater than HAVE_METADATA, even if doing so requires fetching multiple parts of the resource.

When the length of the media resource changes to a known value (e.g. from being unknown to known, or from a previously established length to a new length) the user agent must queue a task to fire a simple event named durationchange at the media element. (The event is not fired when the duration is reset as part of loading a new media resource.) If the duration is changed such that the current playback position ends up being greater than the time of the end of the media resource, then the user agent must also seek to the time of the end of the media resource.

If an "infinite" stream ends for some reason, then the duration would change from positive Infinity to the time of the last frame or sample in the stream, and the durationchange event would be fired. Similarly, if the user agent initially estimated the media resource's duration instead of determining it precisely, and later revises the estimate based on new information, then the duration would change and the durationchange event would be fired.

Some video files also have an explicit date and time corresponding to the zero time in the media timeline, known as the timeline offset. Initially, the timeline offset must be set to Not-a-Number (NaN).

The getStartDate() method must return a new Date object representing the current timeline offset.


loop属性は真停属性であり、指定される堎合、終端に達するずメディアリ゜ヌスの先頭に戻っおシヌクするメディア芁玠であるこずを瀺す。

芁玠が珟圚のメディアコントロヌラを持぀䞀方で、loop属性は効果がない。

The loop IDL attribute must reflect the content attribute of the same name.

4.7.10.7 準備状態
media . readyState

以䞋のリストのコヌドから、珟圚の再生䜍眮をレンダリングに察する芁玠の珟圚の状態を衚す倀を返す。

Media elements have a ready state, which describes to what degree they are ready to be rendered at the current playback position. The possible values are as follows; the ready state of a media element at any particular time is the greatest value describing the state of the element:

HAVE_NOTHING数倀0

メディアリ゜ヌスに関する情報が入手できない。珟圚の再生䜍眮のデヌタが入手できない。networkState属性がNETWORK_EMPTYに蚭定されるメディア芁玠は垞にHAVE_NOTHING状態にある。

HAVE_METADATA数倀1

リ゜ヌスの継続時間が䜿甚可胜であるような、十分なリ゜ヌスが埗られおいる。video芁玠の堎合、ビデオの寞法もたた利甚可胜である。シヌク時にAPIはもはや䟋倖を投げない。メディアデヌタは、すぐに珟圚の再生䜍眮に察しお利甚できない。

HAVE_CURRENT_DATA数倀2

盎接の珟圚の再生䜍眮に察するデヌタは䜿甚可胜であるが、盎ちにHAVE_METADATA状態に戻るこずなく、たったく再生方向にない珟圚の再生䜍眮を正垞に進めるこずができるナヌザヌ゚ヌゞェントを利甚可胜ずするのに十分なデヌタがないか、再生方向で入手するためのこれ以䞊デヌタが存圚しないかのいずれかである。たずえば、ビデオにおいお珟圚の再生䜍眮が珟圚のフレヌムの端にある、および再生が終了した堎合、これは次のフレヌムではなく、珟圚のフレヌムからデヌタを持぀ナヌザヌ゚ヌゞェントに察応する。

HAVE_FUTURE_DATA数倀3

盎接の珟圚の再生䜍眮に察するデヌタが利甚可胜であり、盎ちにHAVE_METADATAの状態に戻るこずなく、少なくずも再生方向での珟圚の再生䜍眮を進めるためのナヌザヌ゚ヌゞェントに察する十分なデヌタが同様にあり、テキストトラックは準備が敎う。たずえば、ビデオにおいお、珟圚の再生䜍眮が2぀のフレヌム間の瞬間である際に、少なくずも珟圚のフレヌムず次のフレヌムに察するデヌタを持぀ナヌザヌ゚ヌゞェントにこれは察応するか、珟圚の再生䜍眮がフレヌムの途䞭にある際、少なくずも再生を維持するための珟圚のフレヌムず音声デヌタに察するビデオデヌタを持぀ナヌザヌ゚ヌゞェントに察応する。この堎合においお、珟圚の再生䜍眮は進めるこずはできないので、再生が終了した堎合にナヌザヌ゚ヌゞェントはこの状態にはならない。

HAVE_ENOUGH_DATA数倀4

HAVE_FUTURE_DATA状態に぀いお説明されるすべおの条件が満たされ、加えお、以䞋のいずれかの条件が真である

実際には、HAVE_METADATAずHAVE_CURRENT_DATAずの違いはごくわずかである。canvasにvideo芁玠を描画する際のみ、本圓に違いが関連しおいる。ここで、䜕かが描画されるHAVE_CURRENT_DATA以䞊堎合ず䜕も描画されないHAVE_METADATA以䞋堎合を区別する。同様に、HAVE_CURRENT_DATA珟圚のフレヌムのみずHAVE_FUTURE_DATA少なくずもこのフレヌムず次の差は、無芖できる極端には、1フレヌムだけ。ペヌゞが"フレヌムごずの"ナビゲヌションにむンタヌフェヌスを提䟛する際に、方向が本圓に重芁な単なる時間である。

When the ready state of a media element whose networkState is not NETWORK_EMPTY changes, the user agent must follow the steps given below:

  1. Apply the first applicable set of substeps from the following list:

    If the previous ready state was HAVE_NOTHING, and the new ready state is HAVE_METADATA

    Queue a task to fire a simple event named loadedmetadata at the element.

    Before this task is run, as part of the event loop mechanism, the rendering will have been updated to resize the video element if appropriate.

    If the previous ready state was HAVE_METADATA and the new ready state is HAVE_CURRENT_DATA or greater

    If this is the first time this occurs for this media element since the load() algorithm was last invoked, the user agent must queue a task to fire a simple event named loadeddata at the element.

    If the new ready state is HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA, then the relevant steps below must then be run also.

    If the previous ready state was HAVE_FUTURE_DATA or more, and the new ready state is HAVE_CURRENT_DATA or less

    If the media element was potentially playing before its readyState attribute changed to a value lower than HAVE_FUTURE_DATA, and the element has not ended playback, and playback has not stopped due to errors, paused for user interaction, or paused for in-band content, the user agent must queue a task to fire a simple event named timeupdate at the element, and queue a task to fire a simple event named waiting at the element.

    If the previous ready state was HAVE_CURRENT_DATA or less, and the new ready state is HAVE_FUTURE_DATA

    The user agent must queue a task to fire a simple event named canplay at the element.

    If the element's paused attribute is false, the user agent must queue a task to fire a simple event named playing at the element.

    If the new ready state is HAVE_ENOUGH_DATA

    If the previous ready state was HAVE_CURRENT_DATA or less, the user agent must queue a task to fire a simple event named canplay at the element, and, if the element's paused attribute is false, queue a task to fire a simple event named playing at the element.

    If the autoplaying flag is true, and the paused attribute is true, and the media element has an autoplay attribute specified, and the media element's Document's active sandboxing flag set does not have the sandboxed automatic features browsing context flag set, then the user agent may also run the following substeps:

    1. Set the paused attribute to false.
    2. If the element's show poster flag is true, set it to false and run the time marches on steps.
    3. Queue a task to fire a simple event named play at the element.
    4. Queue a task to fire a simple event named playing at the element.

    User agents do not need to support autoplay, and it is suggested that user agents honor user preferences on the matter. Authors are urged to use the autoplay attribute rather than using script to force the video to play, so as to allow the user to override the behavior if so desired.

    In any case, the user agent must finally queue a task to fire a simple event named canplaythrough at the element.

  2. If the media element has a current media controller, then report the controller state for the media element's current media controller.

メディア芁玠の準備状態は、これらの状態間を䞍連続にゞャンプするこずが可胜である。たずえば、メディア芁玠の状態は、HAVE_CURRENT_DATAずHAVE_FUTURE_DATA状態を経由せずにHAVE_METADATAからHAVE_ENOUGH_DATAに盎接ゞャンプできる。

The readyState IDL attribute must, on getting, return the value described above that describes the current ready state of the media element.

autoplay属性は真停属性である。When present, the user agent (as described in the algorithm described herein) will automatically begin playback of the media resource as soon as it can do so without stopping.

著者は、望たれない堎合、たずえばスクリヌンリヌダヌを䜿甚する堎合、ナヌザヌが自動再生を䞊曞きできるよう、自動再生を誘発するためのスクリプトを䜿甚するよりも、autoplay属性を䜿甚するように促される。著者はたた、䞀切自動再生の動䜜を䜿甚するこずなく、代わりに明瀺的に再生を開始するためのナヌザヌに察しおナヌザヌ゚ヌゞェントが埅機しないよう考慮するこずが掚奚される。

The autoplay IDL attribute must reflect the content attribute of the same name.

4.7.10.8 メディアリ゜ヌスの再生
media . paused

再生が䞀時停止された堎合はtrueを返し、そうでなければfalseを返す。

media . ended

再生がメディアリ゜ヌスの終わりに達した堎合trueを返す。

media . defaultPlaybackRate [ = value ]

メディアリ゜ヌスを介しおナヌザヌが早送りたたは巻き戻ししない堎合に察し、再生のデフォルト率を返す。

再生のデフォルト率を倉曎する蚭定が可胜である。

デフォルト率は再生に盎接圱響を䞎えないが、ナヌザヌが早送りモヌドに切り替えた堎合、モヌドが通垞の再生モヌドに戻った際に、再生速床が再生のデフォルト率に戻されるこずが期埅される。

芁玠が珟圚のメディアコントロヌラを持぀堎合、defaultPlaybackRate属性は無芖され、珟圚のメディアコントロヌラのdefaultPlaybackRateが代わりに䜿甚される。

media . playbackRate [ = value ]

珟圚の再生率を返す。ここで1.0が通垞の速床である。

再生速床を倉曎する蚭定が可胜である。

芁玠が珟圚のメディアコントロヌラを持぀堎合、playbackRate属性は無芖され、珟圚のメディアコントロヌラのplaybackRateが代わりに䜿甚される。

media . played

ナヌザヌ゚ヌゞェントが再生したメディアリ゜ヌスの範囲を衚すTimeRangesオブゞェクトを返す。

media . play()

必芁に応じおメディアリ゜ヌスを読み蟌んで再生を開始し、paused属性をfalseに蚭定する。再生が終了した堎合、最初からリ゜ヌスを再スタヌトする。

media . pause()

必芁に応じお、メディアリ゜ヌスを読み蟌み、paused属性をtrueに蚭定する。

The paused attribute represents whether the media element is paused or not. The attribute must initially be true.

A media element is a blocked media element if its readyState attribute is in the HAVE_NOTHING state, the HAVE_METADATA state, or the HAVE_CURRENT_DATA state, or if the element has paused for user interaction or paused for in-band content.

A media element is said to be potentially playing when its paused attribute is false, the element has not ended playback, playback has not stopped due to errors, the element either has no current media controller or has a current media controller but is not blocked on its media controller, and the element is not a blocked media element.

A waiting DOM event can be fired as a result of an element that is potentially playing stopping playback due to its readyState attribute changing to a value lower than HAVE_FUTURE_DATA.

A media element is said to have ended playback when:

The ended attribute must return true if, the last time the event loop reached step 1, the media element had ended playback and the direction of playback was forwards, and false otherwise.

A media element is said to have stopped due to errors when the element's readyState attribute is HAVE_METADATA or greater, and the user agent encounters a non-fatal error during the processing of the media data, and due to that error, is not able to play the content at the current playback position.

A media element is said to have paused for user interaction when its paused attribute is false, the readyState attribute is either HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA and the user agent has reached a point in the media resource where the user has to make a selection for the resource to continue. If the media element has a current media controller when this happens, then the user agent must report the controller state for the media element's current media controller. If the media element has a current media controller when the user makes a selection, allowing playback to resume, the user agent must similarly report the controller state for the media element's current media controller.

It is possible for a media element to have both ended playback and paused for user interaction at the same time.

When a media element that is potentially playing stops playing because it has paused for user interaction, the user agent must queue a task to fire a simple event named timeupdate at the element.

A media element is said to have paused for in-band content when its paused attribute is false, the readyState attribute is either HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA and the user agent has suspended playback of the media resource in order to play content that is temporally anchored to the media resource and has a non-zero length, or to play content that is temporally anchored to a segment of the media resource but has a length longer than that segment. If the media element has a current media controller when this happens, then the user agent must report the controller state for the media element's current media controller. If the media element has a current media controller when the user agent unsuspends playback, the user agent must similarly report the controller state for the media element's current media controller.

One example of when a media element would be paused for in-band content is when the user agent is playing audio descriptions from an external WebVTT file, and the synthesized speech generated for a cue is longer than the time between the text track cue start time and the text track cue end time.


When the current playback position reaches the end of the media resource when the direction of playback is forwards, then the user agent must follow these steps:

  1. If the media element has a loop attribute specified and does not have a current media controller, then seek to the earliest possible position of the media resource and abort these steps.

  2. As defined above, the ended IDL attribute starts returning true once the event loop's current task ends.

  3. Queue a task to fire a simple event named timeupdate at the media element.

  4. Queue a task that, if the media element does not have a current media controller, and the media element has still ended playback, and the direction of playback is still forwards, and paused is false, changes paused to true and fires a simple event named pause at the media element.

  5. Queue a task to fire a simple event named ended at the media element.

  6. If the media element has a current media controller, then report the controller state for the media element's current media controller.

When the current playback position reaches the earliest possible position of the media resource when the direction of playback is backwards, then the user agent must only queue a task to fire a simple event named timeupdate at the element.


The defaultPlaybackRate attribute gives the desired speed at which the media resource is to play, as a multiple of its intrinsic speed. The attribute is mutable: on getting it must return the last value it was set to, or 1.0 if it hasn't yet been set; on setting the attribute must be set to the new value.

The defaultPlaybackRate is used by the user agent when it exposes a user interface to the user.

The playbackRate attribute gives the effective playback rate (assuming there is no current media controller overriding it), which is the speed at which the media resource plays, as a multiple of its intrinsic speed. If it is not equal to the defaultPlaybackRate, then the implication is that the user is using a feature such as fast forward or slow motion playback. The attribute is mutable: on getting it must return the last value it was set to, or 1.0 if it hasn't yet been set; on setting the attribute must be set to the new value, and the playback will change speed (if the element is potentially playing and there is no current media controller).

When the defaultPlaybackRate or playbackRate attributes change value (either by being set by script or by being changed directly by the user agent, e.g. in response to user control) the user agent must queue a task to fire a simple event named ratechange at the media element.

The defaultPlaybackRate and playbackRate attributes have no effect when the media element has a current media controller; the namesake attributes on the MediaController object are used instead in that situation.


The played attribute must return a new static normalized TimeRanges object that represents the ranges of points on the media timeline of the media resource reached through the usual monotonic increase of the current playback position during normal playback, if any, at the time the attribute is evaluated.


When the play() method on a media element is invoked, the user agent must run the following steps.

  1. If the media element's networkState attribute has the value NETWORK_EMPTY, invoke the media element's resource selection algorithm.

  2. If the playback has ended and the direction of playback is forwards, and the media element does not have a current media controller, seek to the earliest possible position of the media resource.

    This will cause the user agent to queue a task to fire a simple event named timeupdate at the media element.

  3. If the media element has a current media controller, then bring the media element up to speed with its new media controller.

  4. If the media element's paused attribute is true, run the following substeps:

    1. Change the value of paused to false.

    2. If the show poster flag is true, set the element's show poster flag to false and run the time marches on steps.

    3. Queue a task to fire a simple event named play at the element.

    4. If the media element's readyState attribute has the value HAVE_NOTHING, HAVE_METADATA, or HAVE_CURRENT_DATA, queue a task to fire a simple event named waiting at the element.

      Otherwise, the media element's readyState attribute has the value HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA: queue a task to fire a simple event named playing at the element.

  5. Set the media element's autoplaying flag to false.

  6. If the media element has a current media controller, then report the controller state for the media element's current media controller.


When the pause() method is invoked, and when the user agent is required to pause the media element, the user agent must run the following steps:

  1. If the media element's networkState attribute has the value NETWORK_EMPTY, invoke the media element's resource selection algorithm.

  2. Set the media element's autoplaying flag to false.

  3. If the media element's paused attribute is false, run the following steps:

    1. Change the value of paused to true.

    2. Queue a task to fire a simple event named timeupdate at the element.

    3. Queue a task to fire a simple event named pause at the element.

    4. Set the official playback position to the current playback position.

  4. If the media element has a current media controller, then report the controller state for the media element's current media controller.


The effective playback rate is not necessarily the element's playbackRate. When a media element has a current media controller, its effective playback rate is the MediaController's media controller playback rate. Otherwise, the effective playback rate is just the element's playbackRate. Thus, the current media controller overrides the media element.

If the effective playback rate is positive or zero, then the direction of playback is forwards. Otherwise, it is backwards.

When a media element is potentially playing and its Document is a fully active Document, its current playback position must increase monotonically at effective playback rate units of media time per unit time of the media timeline's clock. (This specification always refers to this as an increase, but that increase could actually be a decrease if the effective playback rate is negative.)

The effective playback rate can be 0.0, in which case the current playback position doesn't move, despite playback not being paused (paused doesn't become true, and the pause event doesn't fire).

This specification doesn't define how the user agent achieves the appropriate playback rate — depending on the protocol and media available, it is plausible that the user agent could negotiate with the server to have the server provide the media data at the appropriate rate, so that (except for the period between when the rate is changed and when the server updates the stream's playback rate) the client doesn't actually have to drop or interpolate any frames.

Any time the user agent provides a stable state, the official playback position must be set to the current playback position.

When the direction of playback is backwards, any corresponding audio must be muted. When the effective playback rate is so low or so high that the user agent cannot play audio usefully, the corresponding audio must also be muted. If the effective playback rate is not 1.0, the user agent may apply pitch adjustments to the audio as necessary to render it faithfully.

Media elements that are potentially playing while not in a Document must not play any video, but should play any audio component. Media elements must not stop playing just because all references to them have been removed; only once a media element is in a state where no further audio could ever be played by that element may the element be garbage collected.

It is possible for an element to which no explicit references exist to play audio, even if such an element is not still actively playing: for instance, it could have a current media controller that still has references and can still be unpaused, or it could be unpaused but stalled waiting for content to buffer.


Each media element has a list of newly introduced cues, which must be initially empty. Whenever a text track cue is added to the list of cues of a text track that is in the list of text tracks for a media element, that cue must be added to the media element's list of newly introduced cues. Whenever a text track is added to the list of text tracks for a media element, all of the cues in that text track's list of cues must be added to the media element's list of newly introduced cues. When a media element's list of newly introduced cues has new cues added while the media element's show poster flag is not set, then the user agent must run the time marches on steps.

When a text track cue is removed from the list of cues of a text track that is in the list of text tracks for a media element, and whenever a text track is removed from the list of text tracks of a media element, if the media element's show poster flag is not set, then the user agent must run the time marches on steps.

When the current playback position of a media element changes (e.g. due to playback or seeking), the user agent must run the time marches on steps. If the current playback position changes while the steps are running, then the user agent must wait for the steps to complete, and then must immediately rerun the steps. (These steps are thus run as often as possible or needed — if one iteration takes a long time, this can cause certain cues to be skipped over as the user agent rushes ahead to "catch up".)

The time marches on steps are as follows:

  1. Let current cues be a list of cues, initialized to contain all the cues of all the hidden or showing text tracks of the media element (not the disabled ones) whose start times are less than or equal to the current playback position and whose end times are greater than the current playback position.

  2. Let other cues be a list of cues, initialized to contain all the cues of hidden and showing text tracks of the media element that are not present in current cues.

  3. Let last time be the current playback position at the time this algorithm was last run for this media element, if this is not the first time it has run.

  4. If the current playback position has, since the last time this algorithm was run, only changed through its usual monotonic increase during normal playback, then let missed cues be the list of cues in other cues whose start times are greater than or equal to last time and whose end times are less than or equal to the current playback position. Otherwise, let missed cues be an empty list.

  5. Remove all the cues in missed cues that are also in the media element's list of newly introduced cues, and then empty the element's list of newly introduced cues.

  6. If the time was reached through the usual monotonic increase of the current playback position during normal playback, and if the user agent has not fired a timeupdate event at the element in the past 15 to 250ms and is not still running event handlers for such an event, then the user agent must queue a task to fire a simple event named timeupdate at the element. (In the other cases, such as explicit seeks, relevant events get fired as part of the overall process of changing the current playback position.)

    The event thus is not to be fired faster than about 66Hz or slower than 4Hz (assuming the event handlers don't take longer than 250ms to run). User agents are encouraged to vary the frequency of the event based on the system load and the average cost of processing the event each time, so that the UI updates are not any more frequent than the user agent can comfortably handle while decoding the video.

  7. If all of the cues in current cues have their text track cue active flag set, none of the cues in other cues have their text track cue active flag set, and missed cues is empty, then abort these steps.

  8. If the time was reached through the usual monotonic increase of the current playback position during normal playback, and there are cues in other cues that have their text track cue pause-on-exit flag set and that either have their text track cue active flag set or are also in missed cues, then immediately pause the media element.

    In the other cases, such as explicit seeks, playback is not paused by going past the end time of a cue, even if that cue has its text track cue pause-on-exit flag set.

  9. Let events be a list of tasks, initially empty. Each task in this list will be associated with a text track, a text track cue, and a time, which are used to sort the list before the tasks are queued.

    Let affected tracks be a list of text tracks, initially empty.

    When the steps below say to prepare an event named event for a text track cue target with a time time, the user agent must run these substeps:

    1. Let track be the text track with which the text track cue target is associated.

    2. Create a task to fire a simple event named event at target.

    3. Add the newly created task to events, associated with the time time, the text track track, and the text track cue target.

    4. Add track to affected tracks.

  10. For each text track cue in missed cues, prepare an event named enter for the TextTrackCue object with the text track cue start time.

  11. For each text track cue in other cues that either has its text track cue active flag set or is in missed cues, prepare an event named exit for the TextTrackCue object with the later of the text track cue end time and the text track cue start time.

  12. For each text track cue in current cues that does not have its text track cue active flag set, prepare an event named enter for the TextTrackCue object with the text track cue start time.

  13. Sort the tasks in events in ascending time order (tasks with earlier times first).

    Further sort tasks in events that have the same time by the relative text track cue order of the text track cues associated with these tasks.

    Finally, sort tasks in events that have the same time and same text track cue order by placing tasks that fire enter events before those that fire exit events.

  14. Queue each task in events, in list order.

  15. Sort affected tracks in the same order as the text tracks appear in the media element's list of text tracks, and remove duplicates.

  16. For each text track in affected tracks, in the list order, queue a task to fire a simple event named cuechange at the TextTrack object, and, if the text track has a corresponding track element, to then fire a simple event named cuechange at the track element as well.

  17. Set the text track cue active flag of all the cues in the current cues, and unset the text track cue active flag of all the cues in the other cues.

  18. Run the rules for updating the text track rendering of each of the text tracks in affected tracks that are showing. For example, for text tracks based on WebVTT, the rules for updating the display of WebVTT text tracks. [WEBVTT]

For the purposes of the algorithm above, a text track cue is considered to be part of a text track only if it is listed in the text track list of cues, not merely if it is associated with the text track.

If the media element's Document stops being a fully active document, then the playback will stop until the document is active again.

When a media element is removed from a Document, the user agent must run the following steps:

  1. Asynchronously await a stable state, allowing the task that removed the media element from the Document to continue. The synchronous section consists of all the remaining steps of this algorithm. (Steps in the synchronous section are marked with ⌛.)

  2. ⌛ If the media element is in a Document, abort these steps.

  3. ⌛ If the media element's networkState attribute has the value NETWORK_EMPTY, abort these steps.

  4. ⌛ Pause the media element.

4.7.10.9 シヌク
media . seeking

ナヌザヌ゚ヌゞェントが珟圚シヌクしおいる堎合にtrueを返す。

media . seekable

ナヌザヌ゚ヌゞェントがシヌク可胜であるメディアリ゜ヌスの範囲を衚すTimeRangesオブゞェクトを返す。

The seeking attribute must initially have the value false.

When the user agent is required to seek to a particular new playback position in the media resource, optionally with the approximate-for-speed flag set, it means that the user agent must run the following steps. This algorithm interacts closely with the event loop mechanism; in particular, it has a synchronous section (which is triggered as part of the event loop algorithm). Steps in that section are marked with ⌛.

  1. Set the media element's show poster flag to false.

  2. If the media element's readyState is HAVE_NOTHING, abort these steps.

  3. If the element's seeking IDL attribute is true, then another instance of this algorithm is already running. Abort that other instance of the algorithm without waiting for the step that it is running to complete.

  4. Set the seeking IDL attribute to true.

  5. If the seek was in response to a DOM method call or setting of an IDL attribute, then continue the script. The remainder of these steps must be run asynchronously. With the exception of the steps marked with ⌛, they could be aborted at any time by another instance of this algorithm being invoked.

  6. If the new playback position is later than the end of the media resource, then let it be the end of the media resource instead.

  7. If the new playback position is less than the earliest possible position, let it be that position instead.

  8. If the (possibly now changed) new playback position is not in one of the ranges given in the seekable attribute, then let it be the position in one of the ranges given in the seekable attribute that is the nearest to the new playback position. If two positions both satisfy that constraint (i.e. the new playback position is exactly in the middle between two ranges in the seekable attribute) then use the position that is closest to the current playback position. If there are no ranges given in the seekable attribute then set the seeking IDL attribute to false and abort these steps.

  9. If the approximate-for-speed flag is set, adjust the new playback position to a value that will allow for playback to resume promptly. If new playback position before this step is before current playback position, then the adjusted new playback position must also be before the current playback position. Similarly, if the new playback position before this step is after current playback position, then the adjusted new playback position must also be after the current playback position.

    For example, the user agent could snap to the nearest key frame, so that it doesn't have to spend time decoding then discarding intermediate frames before resuming playback.

  10. Queue a task to fire a simple event named seeking at the element.

  11. Set the current playback position to the given new playback position.

    If the media element was potentially playing immediately before it started seeking, but seeking caused its readyState attribute to change to a value lower than HAVE_FUTURE_DATA, then a waiting will be fired at the element.

    The currentTime attribute does not get updated asynchronously, as it returns the official playback position, not the current playback position.

  12. Wait until the user agent has established whether or not the media data for the new playback position is available, and, if it is, until it has decoded enough data to play back that position.

  13. Await a stable state. The synchronous section consists of all the remaining steps of this algorithm. (Steps in the synchronous section are marked with ⌛.)

  14. ⌛ Set the seeking IDL attribute to false.

  15. ⌛ Run the time marches on steps.

  16. ⌛ Queue a task to fire a simple event named timeupdate at the element.

  17. ⌛ Queue a task to fire a simple event named seeked at the element.


The seekable attribute must return a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent is able to seek to, at the time the attribute is evaluated.

If the user agent can seek to anywhere in the media resource, e.g. because it is a simple movie file and the user agent and the server support HTTP Range requests, then the attribute would return an object with one range, whose start is the time of the first frame (the earliest possible position, typically zero), and whose end is the same as the time of the first frame plus the duration attribute's value (which would equal the time of the last frame, and might be positive Infinity).

The range might be continuously changing, e.g. if the user agent is buffering a sliding window on an infinite stream. This is the behavior seen with DVRs viewing live TV, for instance.

Media resources might be internally scripted or interactive. Thus, a media element could play in a non-linear fashion. If this happens, the user agent must act as if the algorithm for seeking was used whenever the current playback position changes in a discontinuous fashion (so that the relevant events fire). If the media element has a current media controller, then the user agent must seek the media controller appropriately instead.

4.7.10.10 耇数のメディアトラックを䌎うメディアリ゜ヌス

メディアリ゜ヌス は、耇数の埋め蟌みオヌディオおよびビデオトラックを持぀こずができる。たずえば、䞻ビデオトラックずオヌディオトラックに加えお、メディアリ゜ヌスは、倖囜語吹き替えのやりずり、監督の解説、音声による説明、代替アングル、たたは手話のオヌバヌレむを持぀かもしれない。

media . audioTracks

メディアリ゜ヌスで䜿甚可胜なオヌディオトラックを衚すAudioTrackListオブゞェクトを返す。

media . videoTracks

メディアリ゜ヌスで䜿甚可胜なビデオトラックを衚すVideoTrackListオブゞェクトを返す。

The audioTracks attribute of a media element must return a live AudioTrackList object representing the audio tracks available in the media element's media resource. The same object must be returned each time.

The videoTracks attribute of a media element must return a live VideoTrackList object representing the video tracks available in the media element's media resource. The same object must be returned each time.

There are only ever one AudioTrackList object and one VideoTrackList object per media element, even if another media resource is loaded into the element: the objects are reused. (The AudioTrack and VideoTrack objects are not, though.)

この䟋においお、スクリプトは、ビデオおよび動画が配眮される芁玠の参照ぞのURLを取埗する関数を定矩する。その機胜はビデオの読み蟌みを詊み、そしお、䞀床読み蟌たれるず、利甚可胜な手話トラックがあるかどうかをチェックする。存圚する堎合、そのトラックも衚瀺する。䞡方のトラックは䞎えられたコンテナにのみ配眮される。スタむルが巧劙な方法でこの䜜業を行うために適甚されるこずを前提にしおいる。

<script>
 function loadVideo(url, container) {
   var controller = new MediaController();
   var video = document.createElement('video');
   video.src = url;
   video.autoplay = true;
   video.controls = true;
   video.controller = controller;
   container.appendChild(video);
   video.onloadedmetadata = function (event) {
     for (var i = 0; i < video.videoTracks.length; i += 1) {
       if (video.videoTracks[i].kind == 'sign') {
         var sign = document.createElement('video');
         sign.src = url + '#track=' + video.videoTracks[i].id; 
         sign.autoplay = true;
         sign.controller = controller;
         container.appendChild(sign);
         return;
       }
     }
   };
 }
</script>
4.7.10.10.1 AudioTrackListおよびVideoTrackListオブゞェクト

AudioTrackListおよびVideoTrackListむンタヌフェヌスは、前節で定矩された属性で䜿甚される。

interface AudioTrackList : EventTarget {
  readonly attribute unsigned long length;
  getter AudioTrack (unsigned long index);
  AudioTrack? getTrackById(DOMString id);

           attribute EventHandler onchange;
           attribute EventHandler onaddtrack;
           attribute EventHandler onremovetrack;
};

interface AudioTrack {
  readonly attribute DOMString id;
  readonly attribute DOMString kind;
  readonly attribute DOMString label;
  readonly attribute DOMString language;
           attribute boolean enabled;
};

interface VideoTrackList : EventTarget {
  readonly attribute unsigned long length;
  getter VideoTrack (unsigned long index);
  VideoTrack? getTrackById(DOMString id);
  readonly attribute long selectedIndex;

           attribute EventHandler onchange;
           attribute EventHandler onaddtrack;
           attribute EventHandler onremovetrack;
};

interface VideoTrack {
  readonly attribute DOMString id;
  readonly attribute DOMString kind;
  readonly attribute DOMString label;
  readonly attribute DOMString language;
           attribute boolean selected;
};
media . audioTracks . length
media . videoTracks . length

リスト内のトラックの数を返す。

audioTrack = media . audioTracks[index]
videoTrack = media . videoTracks[index]

指定AudioTrackたたはVideoTrackオブゞェクトを返す。

audioTrack = media . audioTracks . getTrackById( id )
videoTrack = media . videoTracks . getTrackById( id )

䞎えられた識別子ずずもにAudioTrackたたはVideoTrackオブゞェクトを返す、たたは䞀切トラックがその識別子を持たない堎合nullを返す。

audioTrack . id
videoTrack . id

指定されたトラックのIDを返す。フォヌマットがMedia Fragments URI構文をサポヌトし、getTrackById()メ゜ッドずずもに䜿甚できる堎合、これは、フラグメント識別子で䜿甚できるIDである。[MEDIAFRAG]

audioTrack . kind
videoTrack . kind

䞎えられたトラックに該圓するカテゎリを返す。可胜なトラックカテゎリは以䞋の通り。

audioTrack . label
videoTrack . label

既知の堎合、指定されたトラックのラベルを返し、そうでなければ空文字列を返す。

audioTrack . language
videoTrack . language

既知の堎合、指定されたトラックの蚀語を返し、そうでなければ空の文字列を返す。

audioTrack . enabled [ = value ]

指定されたトラックがアクティブである堎合、trueを返し、そうでなければfalseを返す。

トラックが有効かどうかを倉曎する蚭定が可胜である。耇数のオヌディオトラックが同時に有効である堎合、それらが混圚しおいる。

media . videoTracks . selectedIndex

もしあれば、珟圚遞択されおいるトラックのむンデックスを返し、そうでなければ-1を返す。

videoTrack . selected [ = value ]

指定されたトラックがアクティブである堎合、trueを返し、そうでなければfalseを返す。

トラックが遞択されるかどうかを倉曎する蚭定が可胜である。0個たたは1぀のいずれかのビデオトラックが遞択される。前の1぀が遞択されおいる間に新しいトラックを遞択するず、1぀前の遞択を解陀する。

An AudioTrackList object represents a dynamic list of zero or more audio tracks, of which zero or more can be enabled at a time. Each audio track is represented by an AudioTrack object.

A VideoTrackList object represents a dynamic list of zero or more video tracks, of which zero or one can be selected at a time. Each video track is represented by a VideoTrack object.

Tracks in AudioTrackList and VideoTrackList objects must be consistently ordered. If the media resource is in a format that defines an order, then that order must be used; otherwise, the order must be the relative order in which the tracks are declared in the media resource. The order used is called the natural order of the list.

Each track in a TrackList thus has an index; the first has the index 0, and each subsequent track is numbered one higher than the previous one. If a media resource dynamically adds or removes audio or video tracks, then the indices of the tracks will change dynamically. If the media resource changes entirely, then all the previous tracks will be removed and replaced with new tracks.

The AudioTrackList.length and VideoTrackList.length attributes must return the number of tracks represented by their objects at the time of getting.

The supported property indices of AudioTrackList and VideoTrackList objects at any instant are the numbers from zero to the number of tracks represented by the respective object minus one, if any tracks are represented. If an AudioTrackList or VideoTrackList object represents no tracks, it has no supported property indices.

To determine the value of an indexed property for a given index index in an AudioTrackList or VideoTrackList object list, the user agent must return the AudioTrack or VideoTrack object that represents the indexth track in list.

The AudioTrackList.getTrackById(id) and VideoTrackList.getTrackById(id) methods must return the first AudioTrack or VideoTrack object (respectively) in the AudioTrackList or VideoTrackList object (respectively) whose identifier is equal to the value of the id argument (in the natural order of the list, as defined above). When no tracks match the given argument, the methods must return null.

The AudioTrack and VideoTrack objects represent specific tracks of a media resource. Each track can have an identifier, category, label, and language. These aspects of a track are permanent for the lifetime of the track; even if a track is removed from a media resource's AudioTrackList or VideoTrackList objects, those aspects do not change.

In addition, AudioTrack objects can each be enabled or disabled; this is the audio track's enabled state. When an AudioTrack is created, its enabled state must be set to false (disabled). The resource fetch algorithm can override this.

Similarly, a single VideoTrack object per VideoTrackList object can be selected, this is the video track's selection state. When a VideoTrack is created, its selection state must be set to false (not selected). The resource fetch algorithm can override this.

The AudioTrack.id and VideoTrack.id attributes must return the identifier of the track, if it has one, or the empty string otherwise. If the media resource is in a format that supports the Media Fragments URI fragment identifier syntax, the identifier returned for a particular track must be the same identifier that would enable the track if used as the name of a track in the track dimension of such a fragment identifier. [MEDIAFRAG]

For example, in Ogg files, this would be the Name header field of the track. [OGGSKELETONHEADERS]

The AudioTrack.kind and VideoTrack.kind attributes must return the category of the track, if it has one, or the empty string otherwise.

The category of a track is the string given in the first column of the table below that is the most appropriate for the track based on the definitions in the table's second and third columns, as determined by the metadata included in the track in the media resource. The cell in the third column of a row says what the category given in the cell in the first column of that row applies to; a category is only appropriate for an audio track if it applies to audio tracks, and a category is only appropriate for video tracks if it applies to video tracks. Categories must only be returned for AudioTrack objects if they are appropriate for audio, and must only be returned for VideoTrack objects if they are appropriate for video.

AudioTrack.kind()およびVideoTrack.kind()に倀を返す
カテゎリ 定矩 適甚察象
"alternative" メむントラックぞの可胜な代替、たずえば、曲の別テむクオヌディオ、たたは別アングルビデオ。 Audioずvideo。
"captions" 焌き付き字幕をも぀䞻ビデオトラックのバヌゞョン。レガシヌコンテンツ甚。新しいコンテンツはテキストトラックを䜿甚する。 Videoのみ。
"descriptions" ビデオトラックの音声解説。 Audioのみ。
"main" 䞻オヌディオたたはビデオトラック。 Audioずvideo。
"main-desc" 音声解説ず混合された、䞻オヌディオトラック。 Audioのみ。
"sign" オヌディオトラックの手話通蚳。 Videoのみ。
"subtitles" 焌き付き字幕をも぀䞻ビデオトラックのバヌゞョン。レガシヌコンテンツ甚。新しいコンテンツはテキストトラックを䜿甚する。 Videoのみ。
"translation" 䞻オヌディオトラックの翻蚳バヌゞョン。 Audioのみ。
"commentary" 䞻オヌディオたたはビデオトラックのコメンタリ。たずえばディレクタヌのコメント。 Audioずvideo。
""空文字列 明瀺的な皮類がないか、トラックのメタデヌタで指定された皮類は、ナヌザヌ゚ヌゞェントによっお認識されない。 Audioずvideo。

The AudioTrack.label and VideoTrack.label attributes must return the label of the track, if it has one, or the empty string otherwise.

The AudioTrack.language and VideoTrack.language attributes must return the BCP 47 language tag of the language of the track, if it has one, or the empty string otherwise. If the user agent is not able to express that language as a BCP 47 language tag (for example because the language information in the media resource's format is a free-form string without a defined interpretation), then the method must return the empty string, as if the track had no language.

Source attribute values for id, kind, label and language of multitrack audio and video tracks as described for the relevant media resource format. [INBANDTRACKS]

The AudioTrack.enabled attribute, on getting, must return true if the track is currently enabled, and false otherwise. On setting, it must enable the track if the new value is true, and disable it otherwise. (If the track is no longer in an AudioTrackList object, then the track being enabled or disabled has no effect beyond changing the value of the attribute on the AudioTrack object.)

Whenever an audio track in an AudioTrackList is enabled or disabled, the user agent must queue a task to fire a simple event named change at the AudioTrackList object.

The VideoTrackList.selectedIndex attribute must return the index of the currently selected track, if any. If the VideoTrackList object does not currently represent any tracks, or if none of the tracks are selected, it must instead return −1.

The VideoTrack.selected attribute, on getting, must return true if the track is currently selected, and false otherwise. On setting, it must select the track if the new value is true, and unselect it otherwise. If the track is in a VideoTrackList, then all the other VideoTrack objects in that list must be unselected. (If the track is no longer in a VideoTrackList object, then the track being selected or unselected has no effect beyond changing the value of the attribute on the VideoTrack object.)

Whenever a track in a VideoTrackList that was previously not selected is selected, the user agent must queue a task to fire a simple event named change at the VideoTrackList object. This task must be queued before the task that fires the resize event, if any.


The following are the event handlers (and their corresponding event handler event types) that must be supported, as event handler IDL attributes, by all objects implementing the AudioTrackList and VideoTrackList interfaces:

むベントハンドラ むベントハンドラむベント型
onchange change
onaddtrack addtrack
onremovetrack removetrack

このセクションに蚘茉されるタスクのタスク゜ヌスは、DOM操䜜タスク゜ヌスである。

4.7.10.10.2 宣蚀的に特定のオヌディオずビデオトラックを遞択する

audioTracksおよびvideoTracks属性はスクリプトを再生すべきそのトラックを遞択できるが、メディアリ゜ヌスのURLのフラグメント識別子で特定のトラックを指定するこずにより、宣蚀的に特定のトラックを遞択するこずも可胜である。フラグメント識別子の圢匏は、メディアリ゜ヌスのMIMEタむプに䟝存する。[RFC2046] [URL]

この䟋においお、Media Fragments URIフラグメント識別子の構文をサポヌトする圢匏を䜿甚するビデオが、ラベル"Alternative"ずしお代替アングルがデフォルトのビデオトラックの代わりに有効にされるように埋め蟌たれおいる。[MEDIAFRAG]

<video src="myvideo#track=Alternative"></video>
4.7.10.11 耇数のメディア芁玠を同期する
4.7.10.11.1 導入

各メディア芁玠はMediaControllerを持぀こずができる。MediaControllerは、たずえば手話通蚳のトラックが同期を取っおビデオトラックに重ねるこずができるような、耇数のメディア芁玠の再生を調敎するオブゞェクトである。

デフォルトで、メディア芁玠はMediaControllerを持たない。暗黙のMediaControllerはmediagroupコンテンツ属性を䜿甚しお割り圓おるこずができる。明瀺的なMediaControllerは、盎接controllerIDL属性を䜿甚しお割り圓おるこずができる。

MediaControllerを䌎うメディア芁玠は、そのコントロヌラに埓属するず蚀われる。MediaControllerは、再生速床ずそれに埓属するメディア芁玠のそれぞれの再生音量を倉曎し、その埓属するメディア芁玠のいずれかが予期せず倱速した堎合、他方が同時に停止するこずを保蚌する。

メディア芁玠がMediaControllerに埓属される堎合、その再生速床は同じMediaControllerの他のトラックのものに固定され、任意のルヌプが無効になる。

4.7.10.11.2 メディアコントロヌラ
enum MediaControllerPlaybackState { "waiting", "playing", "ended" };
[Constructor]
interface MediaController : EventTarget {
  readonly attribute unsigned short readyState; // uses HTMLMediaElement.readyState's values

  readonly attribute TimeRanges buffered;
  readonly attribute TimeRanges seekable;
  readonly attribute unrestricted double duration;
           attribute double currentTime;

  readonly attribute boolean paused;
  readonly attribute MediaControllerPlaybackState playbackState;
  readonly attribute TimeRanges played;
  void pause();
  void unpause();
  void play(); // calls play() on all media elements as well

           attribute double defaultPlaybackRate;
           attribute double playbackRate;

           attribute double volume;
           attribute boolean muted;

           attribute EventHandler onemptied;
           attribute EventHandler onloadedmetadata;
           attribute EventHandler onloadeddata;
           attribute EventHandler oncanplay;
           attribute EventHandler oncanplaythrough;
           attribute EventHandler onplaying;
           attribute EventHandler onended;
           attribute EventHandler onwaiting;

           attribute EventHandler ondurationchange;
           attribute EventHandler ontimeupdate;
           attribute EventHandler onplay;
           attribute EventHandler onpause;
           attribute EventHandler onratechange;
           attribute EventHandler onvolumechange;
};
controller = new MediaController()

新しいMediaControllerオブゞェクトを返す。

media . controller [ = controller ]

もしあれば、メディア芁玠に察する珟圚のMediaControllerを返し、そうでなければnullを返す。

明瀺的なMediaControllerを蚭定するこずが可胜である。もしあれば、蚭定しおmediagroup属性を削陀する。

controller . readyState

MediaControllerは、それがコントロヌラの状態を報告する結果ずしおむベントを発生させた最埌の時間であった状態を返す。この属性の倀は、メディア芁玠のreadyState属性の堎合ず同じである。

controller . buffered

ナヌザヌ゚ヌゞェントが、すべおの埓属メディア芁玠に関連するすべおのメディアのデヌタを持぀時間範囲の共通郚分を衚すTimeRangesオブゞェクトを返す。

controller . seekable

ナヌザヌ゚ヌゞェントが、すべおの埓属メディア芁玠をシヌクできる時間範囲の共通郚分を衚すTimeRangesオブゞェクトを返す。

controller . duration

問題のデヌタが実際にバッファリングされた、たたは盎接シヌク可胜ではないが、無限のストリヌムに察する将来の時間を含むかどうかを考慮しない最も早い再生時点ず最も遅い再生時点の差を返す。メディアが存圚しない堎合は0を返す。

controller . currentTime [ = value ]

秒単䜍で、0時間ず珟圚時間のdurationの間の䜍眮ずしお、珟圚の再生䜍眮を返す。

指定時間にシヌクするために、蚭定可胜である。

controller . paused

再生が䞀時停止された堎合はtrueを返し、そうでなければfalseを返す。この属性がtrueの堎合、このコントロヌラに埓属するすべおのメディア芁玠が停止される。

controller . playbackState

MediaControllerは、それがコントロヌラの状態を報告する結果ずしおむベントを発生させた最埌の時間であった状態を返す。この属性の倀は、メディアが積極的に再生されるこずを瀺す"playing"、すべおの埓属メディア芁玠の最埌に到達しおいるために再生されおいないこずを瀺す"ended"、たたはその他の理由たずえばMediaControllerが䞀時停止されおいるのために再生されおいないこずを瀺す"waiting"のいずれかである。

controller . pause()

trueにpaused属性を蚭定する。

controller . unpause()

falseにpaused属性を蚭定する。

controller . play()

falseにpaused属性を蚭定し、各埓属メディア芁玠のplay()メ゜ッドを呌び出す。

controller . played

再生されおいるすべおの埓属メディア芁玠で時間範囲の和集合を衚すTimeRangesオブゞェクトを返す。

controller . defaultPlaybackRate [ = value ]

再生のデフォルト率を返す。

再生のデフォルト率を倉曎する蚭定が可胜である。

デフォルト率は再生に盎接圱響を䞎えないが、ナヌザヌが早送りモヌドに切り替えた堎合、モヌドが通垞の再生モヌドに戻った際に、再生速床playbackRateがデフォルト率に戻されるこずが期埅される。

controller . playbackRate [ = value ]

再生の珟圚速床を返す。

再生速床を倉曎する蚭定が可胜である。

controller . volume [ = value ]

0.0から1.0たでの範囲の数字ずしお、珟圚の再生音量の乗数を返す。ここで0.0は最小音量で1.0は最倧音量である。

音量の乗数を倉曎する蚭定が可胜である。

新しい倀が範囲0.0から1.0に含たれない堎合、IndexSizeErrorを投げる。

controller . muted [ = value ]

コントロヌラ䞊、たたはこのコントロヌラに埓属する任意のメディア芁玠のいずれかで他の属性に関係なくすべおのオヌディオがミュヌトである堎合、trueを返し、そうでなければfalseを返す。

オヌディオがミュヌトであるかどうかを倉曎する蚭定が可胜である。

A media element can have a current media controller, which is a MediaController object. When a media element is created without a mediagroup attribute, it does not have a current media controller. (If it is created with such an attribute, then that attribute initializes the current media controller, as defined below.)

The slaved media elements of a MediaController are the media elements whose current media controller is that MediaController. All the slaved media elements of a MediaController must use the same clock for their definition of their media timeline's unit time. When the user agent is required to act on each slaved media element in turn, they must be processed in the order that they were last associated with the MediaController.


The controller attribute on a media element, on getting, must return the element's current media controller, if any, or null otherwise. On setting, the user agent must run the following steps:

  1. Let m be the media element in question.

  2. Let old controller be m's current media controller, if it currently has one, and null otherwise.

  3. Let new controller be null.

  4. Let m have no current media controller, if it currently has one.

  5. Remove the element's mediagroup content attribute, if any.

  6. If the new value is null, then jump to the update controllers step below.

  7. Let m's current media controller be the new value.

  8. Let new controller be m's current media controller.

  9. Bring the media element up to speed with its new media controller.

  10. Update controllers: If old controller and new controller are the same (whether both null or both the same controller) then abort these steps.

  11. If old controller is not null and still has one or more slaved media elements, then report the controller state for old controller.

  12. If new controller is not null, then report the controller state for new controller.


The MediaController() constructor, when invoked, must return a newly created MediaController object.


The readyState attribute must return the value to which it was most recently set. When the MediaController object is created, the attribute must be set to the value 0 (HAVE_NOTHING). The value is updated by the report the controller state algorithm below.

The seekable attribute must return a new static normalized TimeRanges object that represents the intersection of the ranges of the media resources of the slaved media elements that the user agent is able to seek to, at the time the attribute is evaluated.

The buffered attribute must return a new static normalized TimeRanges object that represents the intersection of the ranges of the media resources of the slaved media elements that the user agent has buffered, at the time the attribute is evaluated. Users agents must accurately determine the ranges available, even for media streams where this can only be determined by tedious inspection.

The duration attribute must return the media controller duration.

Every 15 to 250ms, or whenever the MediaController's media controller duration changes, whichever happens least often, the user agent must queue a task to fire a simple event named durationchange at the MediaController. If the MediaController's media controller duration decreases such that the media controller position is greater than the media controller duration, the user agent must immediately seek the media controller to media controller duration.

The currentTime attribute must return the media controller position on getting, and on setting must seek the media controller to the new value.

Every 15 to 250ms, or whenever the MediaController's media controller position changes, whichever happens least often, the user agent must queue a task to fire a simple event named timeupdate at the MediaController.


When a MediaController is created it is a playing media controller. It can be changed into a paused media controller and back either via the user agent's user interface (when the element is exposing a user interface to the user) or by script using the APIs defined in this section (see below).

The paused attribute must return true if the MediaController object is a paused media controller, and false otherwise.

When the pause() method is invoked, if the MediaController is a playing media controller then the user agent must change the MediaController into a paused media controller, queue a task to fire a simple event named pause at the MediaController, and then report the controller state of the MediaController.

When the unpause() method is invoked, if the MediaController is a paused media controller, the user agent must change the MediaController into a playing media controller, queue a task to fire a simple event named play at the MediaController, and then report the controller state of the MediaController.

When the play() method is invoked, the user agent must invoke the play() method of each slaved media element in turn, and then invoke the unpause method of the MediaController.

The playbackState attribute must return the value to which it was most recently set. When the MediaController object is created, the attribute must be set to the value "waiting". The value is updated by the report the controller state algorithm below.

The played attribute must return a new static normalized TimeRanges object that represents the union of the ranges of points on the media timelines of the media resources of the slaved media elements that the user agent has so far reached through the usual monotonic increase of their current playback positions during normal playback, at the time the attribute is evaluated.


A MediaController has a media controller default playback rate and a media controller playback rate, which must both be set to 1.0 when the MediaController object is created.

The defaultPlaybackRate attribute, on getting, must return the MediaController's media controller default playback rate, and on setting, must set the MediaController's media controller default playback rate to the new value, then queue a task to fire a simple event named ratechange at the MediaController.

The playbackRate attribute, on getting, must return the MediaController's media controller playback rate, and on setting, must set the MediaController's media controller playback rate to the new value, then queue a task to fire a simple event named ratechange at the MediaController.


A MediaController has a media controller volume multiplier, which must be set to 1.0 when the MediaController object is created, and a media controller mute override, much must initially be false.

The volume attribute, on getting, must return the MediaController's media controller volume multiplier, and on setting, if the new value is in the range 0.0 to 1.0 inclusive, must set the MediaController's media controller volume multiplier to the new value and queue a task to fire a simple event named volumechange at the MediaController. If the new value is outside the range 0.0 to 1.0 inclusive, then, on setting, an IndexSizeError exception must be thrown instead.

The muted attribute, on getting, must return the MediaController's media controller mute override, and on setting, must set the MediaController's media controller mute override to the new value and queue a task to fire a simple event named volumechange at the MediaController.


The media resources of all the slaved media elements of a MediaController have a defined temporal relationship which provides relative offsets between the zero time of each such media resource: for media resources with a timeline offset, their relative offsets are the difference between their timeline offset; the zero times of all the media resources without a timeline offset are not offset from each other (i.e. the origins of their timelines are cotemporal); and finally, the zero time of the media resource with the earliest timeline offset (if any) is not offset from the zero times of the media resources without a timeline offset (i.e. the origins of media resources without a timeline offset are further cotemporal with the earliest defined point on the timeline of the media resource with the earliest timeline offset).

The media resource end position of a media resource in a media element is defined as follows: if the media resource has a finite and known duration, the media resource end position is the duration of the media resource's timeline (the last defined position on that timeline); otherwise, the media resource's duration is infinite or unknown, and the media resource end position is the time of the last frame of media data currently available for that media resource.

Each MediaController also has its own defined timeline. On this timeline, all the media resources of all the slaved media elements of the MediaController are temporally aligned according to their defined offsets. The media controller duration of that MediaController is the time from the earliest earliest possible position, relative to this MediaController timeline, of any of the media resources of the slaved media elements of the MediaController, to the time of the latest media resource end position of the media resources of the slaved media elements of the MediaController, again relative to this MediaController timeline.

Each MediaController has a media controller position. This is the time on the MediaController's timeline at which the user agent is trying to play the slaved media elements. When a MediaController is created, its media controller position is initially zero.

When the user agent is to bring a media element up to speed with its new media controller, it must seek that media element to the MediaController's media controller position relative to the media element's timeline.

When the user agent is to seek the media controller to a particular new playback position, it must follow these steps:

  1. If the new playback position is less than zero, then set it to zero.

  2. If the new playback position is greater than the media controller duration, then set it to the media controller duration.

  3. Set the media controller position to the new playback position.

  4. Seek each slaved media element to the new playback position relative to the media element timeline.

A MediaController is a restrained media controller if the MediaController is a playing media controller, and none of its slaved media elements are blocked media elements, but either at least one of its slaved media elements whose autoplaying flag is true still has its paused attribute set to true, or, all of its slaved media elements have their paused attribute set to true.

A MediaController is a blocked media controller if the MediaController is a paused media controller, or if any of its slaved media elements are blocked media elements, or if any of its slaved media elements whose autoplaying flag is true still have their paused attribute set to true, or if all of its slaved media elements have their paused attribute set to true.

A media element is blocked on its media controller if the MediaController is a blocked media controller, or if its media controller position is either before the media resource's earliest possible position relative to the MediaController's timeline or after the end of the media resource relative to the MediaController's timeline.

When a MediaController is not a blocked media controller and it has at least one slaved media element whose Document is a fully active Document, the MediaController's media controller position must increase monotonically at media controller playback rate units of time on the MediaController's timeline per unit time of the clock used by its slaved media elements.

When the zero point on the timeline of a MediaController moves relative to the timelines of the slaved media elements by a time difference ΔT, the MediaController's media controller position must be decremented by ΔT.

In some situations, e.g. when playing back a live stream without buffering anything, the media controller position would increase monotonically as described above at the same rate as the ΔT described in the previous paragraph decreases it, with the end result that for all intents and purposes, the media controller position would appear to remain constant (probably with the value 0).


A MediaController has a most recently reported readiness state, which is a number from 0 to 4 derived from the numbers used for the media element readyState attribute, and a most recently reported playback state, which is either playing, waiting, or ended.

When a MediaController is created, its most recently reported readiness state must be set to 0, and its most recently reported playback state must be set to waiting.

When a user agent is required to report the controller state for a MediaController, the user agent must run the following steps:

  1. If the MediaController has no slaved media elements, let new readiness state be 0.

    Otherwise, let it have the lowest value of the readyState IDL attributes of all of its slaved media elements.

  2. If the MediaController's most recently reported readiness state is less than the new readiness state, then run these substeps:

    1. Let next state be the MediaController's most recently reported readiness state.

    2. Loop: Increment next state by one.

    3. Queue a task to run the following steps:

      1. Set the MediaController's readyState attribute to the value next state.

      2. Fire a simple event at the MediaController object, whose name is the event name corresponding to the value of next state given in the table below.

    4. If next state is less than new readiness state, then return to the step labeled loop.

    Otherwise, if the MediaController's most recently reported readiness state is greater than new readiness state then queue a task to fire a simple event at the MediaController object, whose name is the event name corresponding to the value of new readiness state given in the table below.

    Value of new readiness state むベント名
    0 emptied
    1 loadedmetadata
    2 loadeddata
    3 canplay
    4 canplaythrough
  3. Let the MediaController's most recently reported readiness state be new readiness state.

  4. Initialize new playback state by setting it to the state given for the first matching condition from the following list:

    If the MediaController has no slaved media elements
    Let new playback state be waiting.
    If all of the MediaController's slaved media elements have ended playback and the media controller playback rate is positive or zero
    Let new playback state be ended.
    If the MediaController is a blocked media controller
    Let new playback state be waiting.
    そうでなければ
    Let new playback state be playing.
  5. If the MediaController's most recently reported playback state is not equal to new playback state and the new playback state is ended, then queue a task that, if the MediaController object is a playing media controller, and all of the MediaController's slaved media elements have still ended playback, and the media controller playback rate is still positive or zero, changes the MediaController object to a paused media controller and then fires a simple event named pause at the MediaController object.

  6. If the MediaController's most recently reported playback state is not equal to new playback state then queue a task to run the following steps:

    1. Set the MediaController's playbackState attribute to the value given in the second column of the row of the following table whose first column contains the new playback state.

    2. Fire a simple event at the MediaController object, whose name is the value given in the third column of the row of the following table whose first column contains the new playback state.

    New playback state New value for playbackState むベント名
    playing "playing" playing
    waiting "waiting" waiting
    ended "ended" ended
  7. Let the MediaController's most recently reported playback state be new playback state.


The following are the event handlers (and their corresponding event handler event types) that must be supported, as event handler IDL attributes, by all objects implementing the MediaController interface:

むベントハンドラ むベントハンドラむベント型
onemptied emptied
onloadedmetadata loadedmetadata
onloadeddata loadeddata
oncanplay canplay
oncanplaythrough canplaythrough
onplaying playing
onended ended
onwaiting waiting
ondurationchange durationchange
ontimeupdate timeupdate
onplay play
onpause pause
onratechange ratechange
onvolumechange volumechange

このセクションに蚘茉されるタスクのタスク゜ヌスは、DOM操䜜タスク゜ヌスである。

4.7.10.11.3 宣蚀的メディアコントロヌラを割り圓おる

メディア芁玠のmediagroupコンテンツ属性は、暗黙的にMediaControllerを䜜成するこずによっお、耇数のメディア芁玠をリンクするために䜿甚できる。倀はテキストである。同じ倀を持぀メディア芁玠はナヌザヌ゚ヌゞェントによっお自動的にリンクされる。

When a media element is created with a mediagroup attribute, and when a media element's mediagroup attribute is set, changed, or removed, the user agent must run the following steps:

  1. Let m be the media element in question.

  2. Let old controller be m's current media controller, if it currently has one, and null otherwise.

  3. Let new controller be null.

  4. Let m have no current media controller, if it currently has one.

  5. If m's mediagroup attribute is being removed, then jump to the update controllers step below.

  6. If there is another media element whose Document is the same as m's Document (even if one or both of these elements are not actually in the Document), and which also has a mediagroup attribute, and whose mediagroup attribute has the same value as the new value of m's mediagroup attribute, then let controller be that media element's current media controller.

    Otherwise, let controller be a newly created MediaController.

  7. Let m's current media controller be controller.

  8. Let new controller be m's current media controller.

  9. Bring the media element up to speed with its new media controller.

  10. Update controllers: If old controller and new controller are the same (whether both null or both the same controller) then abort these steps.

  11. If old controller is not null and still has one or more slaved media elements, then report the controller state for old controller.

  12. If new controller is not null, then report the controller state for new controller.

The mediaGroup IDL attribute on media elements must reflect the mediagroup content attribute.

同じメディアリ゜ヌスを参照する耇数のメディア芁玠は、単䞀のネットワヌク芁求を共有する。これは、画面䞊の2぀の異なる堎所で同じメディアリ゜ヌスから2぀のビデオトラックを効率的に再生するために䜿甚できる。mediagroup属性ず共に䜿甚しお、これらの芁玠はたた同期を維持できる。

この䟋においお、ムヌビヌファむル由来の手話通蚳トラックが、2぀のvideo芁玠、耇数のCSS、および暗黙的なMediaControllerを䜿甚する、その同じビデオファむルの䞻ビデオトラック䞊にオヌバヌレむされる

<article>
 <style>
  div { margin: 1em auto; position: relative; width: 400px; height: 300px; }
  video { position; absolute; bottom: 0; right: 0; }
  video:first-child { width: 100%; height: 100%; }
  video:last-child { width: 30%; }
 </style>
 <div>
  <video src="movie.vid#track=Video&amp;track=English" autoplay controls mediagroup=movie></video>
  <video src="movie.vid#track=sign" autoplay mediagroup=movie></video>
 </div>
</article>
4.7.10.12 時限テキストトラック
4.7.10.12.1 テキストトラックモデル

メディア芁玠は、メディア芁玠のテキストトラックのリストずしお知られ、関連したテキストトラックのグルヌプを持぀こずができる。テキストトラックは以䞋のように゜ヌトされる

  1. ツリヌ順で、メディア芁玠のtrack芁玠の子に察応するテキストトラック。
  2. 叀いものから順で、远加された順に、addTextTrack()メ゜ッドを䜿甚しお远加された任意のテキストトラック。
  3. メディアリ゜ヌスの曞匏仕様によっお定矩された順序で、任意のメディアリ゜ヌス固有のテキストトラックメディアリ゜ヌスが内のデヌタに察応するテキストトラック。

テキストトラックの構成芁玠は次のずおり

テキストトラックの皮類

これは、トラックがナヌザヌ゚ヌゞェントによっお凊理される方法を決定する。皮類は文字列で衚される。可胜性のある文字列は次のずおり

track芁玠に察応するテキストトラックの堎合、トラックの皮類は動的に倉曎できる。

ラベル

これは、ナヌザヌに察するトラックを特定するために意図する刀読可胜な文字列である。

track芁玠に察応するテキストトラックの堎合、トラックのラベルは動的に倉曎できる。

テキストトラックのラベルが空の文字列である堎合、ナヌザヌ゚ヌゞェントは自動的にそのナヌザヌむンタヌフェヌスで䜿甚するためのテキストトラックの他のプロパティヌたずえばテキストトラックの皮類ずテキストトラックの蚀語などから適切なラベルを生成すべきである。この自動生成されたラベルは、APIで公開されない。

垯域内のメタデヌタトラックディスパッチタむプ

これは、文曞内の別のスクリプトに掟遣できるようにするためにトラックを有効にする垯域内メタデヌタトラックに察するメディアリ゜ヌスから抜出された文字列である。

たずえば、りェブ䞊やりェブ固有のむンタラクティブ機胜でのストリヌミングによる埓来のTV局の攟送は、広告察象、ゲヌムショヌの間のトリビアゲヌムデヌタ、スポヌツゲヌムの間の遞手の状態、食糧蚈画䞭のレシピ情報などに察するメタデヌタをも぀テキストトラックを含むかもしれない。各プログラムが開始および終了するず、新しいトラックが远加されたりストリヌムから削陀されたり、各トラックが远加されるず、ナヌザヌ゚ヌゞェントはこの属性倀を䜿甚する専甚のスクリプトモゞュヌルにトラックを結合できる。

垯域内のメタデヌタテキストトラック以倖では、垯域内のメタデヌタトラックディスパッチタむプは、空の文字列である。この倀が異なるメディア圢匏に察しおどのように蚭定されるかは、メディアリ゜ヌス固有のテキストトラックを公開するための手順に蚘茉される。

蚀語

これは、テキストトラックのキュヌの蚀語を衚す文字列BCP 47蚀語タグである。[BCP47]

track芁玠に察応するテキストトラックの堎合、テキストトラックの蚀語は、動的に倉曎できる。

準備状態

以䞋のうちの1぀をずる

ロヌドされおない

テキストトラックのキュヌが埗られおいないこずを瀺す。

ロヌド䞭

テキストトラックがロヌドされおおり、これたでに怜出された臎呜的な゚ラヌがないこずを瀺す。远加のキュヌは、䟝然ずしおパヌサによっおトラックに远加されるかもしれない。

ロヌドされた

テキストトラックが臎呜的な゚ラヌなしでロヌドされたこずを瀺す。

ロヌドに倱敗した

テキストトラックは有効であるが、ナヌザヌ゚ヌゞェントがトラックを取埗しようずした際、これが䜕らかの方法たずえばURLが解決できなかった、ネットワヌク゚ラヌ、未知のテキストトラック圢匏などで倱敗したこずを瀺す。キュヌの䞀郚たたは党郚は、おそらく欠萜しおいるか、含たれおいないだろう。

トラックが埗られるように、テキストトラックの準備状態を動的に倉曎する。

モヌド

以䞋のうちの1぀をずる

無効

テキストトラックがアクティブでないこずを瀺す。DOM内のトラックを公開する目的以倖では、ナヌザヌ゚ヌゞェントはテキストトラックを無芖しおいる。どのキュヌもアクティブでなく、どのむベントも発火せず、ナヌザヌ゚ヌゞェントは、トラックのキュヌを埗るこずを詊みるこずはない。

非衚瀺

テキストトラックがアクティブであるが、ナヌザヌ゚ヌゞェントは、積極的にキュヌを衚瀺しおいないこずを瀺す。どの詊みもただトラックのキュヌを埗るために行われおいない堎合、ナヌザヌ゚ヌゞェントは、䞀瞬そのような詊みを実行する。ナヌザヌ゚ヌゞェントは、キュヌがアクティブであるリストを維持しおおり、むベントはそれに応じお発火されおいる。

衚瀺

テキストトラックがアクティブであるこずを瀺す。どの詊みもただトラックのキュヌを埗るために行われおいない堎合、ナヌザヌ゚ヌゞェントは、䞀瞬そのような詊みを実行する。ナヌザヌ゚ヌゞェントは、キュヌがアクティブであるリストを維持しおおり、むベントはそれに応じお発火されおいる。たた、皮類がsubtitlesやcaptionsであるテキストトラックで、キュヌは必芁に応じおビデオにオヌバヌレむされおいる。皮類がdescriptionsであるテキストトラックで、ナヌザヌ゚ヌゞェントは、非芖芚的な方法でナヌザヌに䜿甚可胜なキュヌを䜜成しおいる。そしお、皮類がchaptersであるテキストトラックで、ナヌザヌ゚ヌゞェントは、ナヌザヌがキュヌを遞択するこずによっおメディアリ゜ヌスの任意のポむントに移動するこずができるメカニズムをナヌザヌに利甚可胜にしおいる。

0個以䞊のキュヌリスト

テキストトラックのレンダリングを曎新するための芏則ずずもに、テキストトラックキュヌのリスト。たずえば、WebVTTに察しお、WebVTTテキストトラックの衚瀺を曎新するための芏則。[WEBVTT]

テキストトラックのキュヌのリストは、テキスト·トラックがただロヌドされおいないか、すでにロヌド䞭である、たたはDOM操䜜に起因しおのいずれかのために、動的に倉曎できる。

各テキストトラックは、察応するTextTrackオブゞェクトを持぀。


各メディア芁玠は、最初は空でなければならない保留䞭のテキストトラックのリスト、最初はfalseでなければならないblocked-on-parserフラグ、最初はfalseでなければならないdid-perform-automatic-track-selectionフラグを持぀。

When the user agent is required to populate the list of pending text tracks of a media element, the user agent must add to the element's list of pending text tracks each text track in the element's list of text tracks whose text track mode is not disabled and whose text track readiness state is loading.

track芁玠の芪ノヌドが倉曎ずきはい぀でも、ナヌザヌ゚ヌゞェントは、芁玠が属する党保留䞭のテキストトラックのリストから該圓するテキストトラックを削陀しなければならない。

テキストトラックのテキストトラックの準備状態がロヌドされるか、ロヌドに倱敗するのいずれかに倉曎されるずきはい぀でも、ナヌザヌ゚ヌゞェントは、テキストトラックが属する党保留䞭のテキストトラックのリストから削陀しなければならない。

メディア芁玠がHTMLパヌサやXMLパヌサによっお䜜成された堎合、ナヌザヌ゚ヌゞェントは、芁玠のblocked-on-parserフラグをtrueに蚭定しなければならない。メディア芁玠がHTMLパヌサやXMLパヌサのオヌプン芁玠のスタックからポップされる堎合、ナヌザヌ゚ヌゞェントは、自動テキストトラックの遞択に察しおナヌザヌの奜みを尊重しなければならず、保留䞭のテキストトラックのリストを远加し、芁玠のblocked-on-parserフラグをfalseに蚭定する。

芁玠の保留䞭のテキストトラックのリストが空であり、芁玠のblocked-on-parserフラグがfalseの䞡方である堎合、メディア芁玠のテキストトラックは準備ができおいる。

各メディア芁玠は、最初に未蚭定でなければならない保留䞭のテキストトラック倉曎通知フラグを持぀。

メディア芁玠のテキストトラックのリストに属するテキストトラックが、そのテキストトラックモヌド倉曎倀を持぀たびに、ナヌザヌ゚ヌゞェントは、メディア芁玠のために次の手順を実行しなければならない

  1. メディア芁玠の保留䞭のテキストトラックの倉曎通知フラグが蚭定される堎合、この手順を䞭止する。

  2. メディア芁玠の保留䞭のテキストトラック倉曎通知フラグを蚭定する。

  3. 次の手順を実行するキュヌタスク

    1. メディア芁玠の保留䞭のテキストトラック倉曎通知フラグを蚭定解陀する。

    2. メディア芁玠のtextTracks属性のTextTrackListオブゞェクトでchangeに名付けられる単玔むベントを発火する。

  4. メディア芁玠のショヌポスタヌフラグが蚭定されおいない堎合、手順の時間行進を実行する。

このセクションに蚘茉されるタスクのタスク゜ヌスは、DOM操䜜タスク゜ヌスである。


テキストトラックキュヌは、特定の時刻に衚瀺され別の時刻に消滅するテキストに字幕やキャプションに察するむンスタンスに察応する、テキストトラックで時刻䟝存のデヌタの単䜍である。

各テキストトラックキュヌの構成は次のずおり

識別子

任意の文字列。

開始時刻

時刻は、秒、秒の小数で、キュヌが適甚されるメディアデヌタの範囲の開始を衚珟する。

終了時刻

時刻は、秒、秒の小数で、キュヌが適甚されるメディアデヌタの範囲の終了を衚珟する。

pause-on-exitフラグ

キュヌが適甚される範囲の最埌に達した際の、メディアリ゜ヌスの再生が䞀時停止するかどうかを瀺す真停倀。

远加の圢匏固有のデヌタ

フォヌマットのために必芁なものずしおの、远加フィヌルド。たずえば、WebVTTは、テキストトラックキュヌ曞き蟌み方向などを持぀。[WEBVTT]

キュヌのデヌタ

キュヌの生デヌタ、および分離しおキュヌをレンダリングするための芏則。

このデヌタの正確な特城は、フォヌマットによっお定矩される。たずえば、WebVTTはテキストを䜿甚する。

テキストトラックキュヌの開始時刻およびテキストトラックキュヌの終了時刻は負であっおもよい。時刻れロがアクティブにするこずはできない前の党䜓のキュヌ、しかし、珟圚の再生䜍眮は負になるこずはない。

各テキストトラックキュヌは、察応するTextTrackCueオブゞェクトより具䜓的には、たずえばWebVTTのキュヌがVTTCueむンタヌフェヌスを䜿甚するような、TextTrackCueを継承したオブゞェクトを持぀。テキストトラックキュヌのメモリ内衚珟は、動的にこのTextTrackCue APIを通しお倉曎できる。[WEBVTT]

テキストトラックキュヌは、テキストトラックキュヌの特定の皮類に察しお仕様で定矩されおいる、テキストトラックレンダリングを曎新するための芏則に関連付けられる。これらの芏則は、キュヌを衚すオブゞェクトがaddCue()メ゜ッドを䜿甚しおTextTrackオブゞェクトに远加される際に特に䜿甚される。

加えお、各テキストトラックキュヌは、動的な2぀の情報を持぀

アクティブフラグ

このフラグは、最初に蚭定を解陀されなければならない。キュヌがアクティブたたは非アクティブになった際、フラグは、むベントが適切に発火されるように、および右のキュヌがレンダリングされるこずを確認するために䜿甚される。

テキストトラックキュヌがそのテキストトラックのキュヌのテキストトラックリストから削陀されるたびに、テキストトラック自䜓はそのメディア芁玠のテキストトラックのリストから削陀される、たたは無効に倉曎されるそのテキストトラックモヌドを持぀たびに、か぀メディア芁玠のreadyStateがHAVE_NOTHINGに戻されるたびに、ナヌザヌ゚ヌゞェントは同期的にこのフラグを蚭定解陀しなければならない。フラグが、関連付垯条件より前に衚瀺されおいたテキストトラック内の1぀以䞊のキュヌに察しおこの方法で解陀される堎合、圱響を受けるすべおのキュヌに察しおフラグを解陀した埌、ナヌザヌ゚ヌゞェントは、これらのテキストトラックに属するテキストトラックのレンダリングを曎新するための芏則を適甚しなければならない。たずえば、WebVTTに基づくテキストトラック甚、WebVTTテキストトラックの衚瀺を曎新するための芏則など。[WEBVTT]

衚瀺状態

これは、䞀貫性のある䜍眮にキュヌを保぀ために、レンダリングモデルの䞀郚ずしお䜿甚される。これは最初は空でなければならない。テキストトラックキュヌのアクティブフラグが蚭定解陀されるたびに、ナヌザヌ゚ヌゞェントはテキストトラックキュヌの衚瀺状態を空にしなければならない。

メディア芁玠のテキストトラックのテキストトラックキュヌは、テキストトラックキュヌ順に互いに盞察的に順序付けされ、以䞋のように決定されるメディア芁玠のテキストトラックのリストに出珟するそれらのテキストトラックずしお同じ順序で゜ヌトされるグルヌプをも぀、それらのテキストトラックで最初のグルヌプのキュヌ次に、各グルヌプ内で、キュヌは、最も早いものの順に、その開始時刻で゜ヌトされなければならない。それから、同じ開始時刻を持぀任意のキュヌは、最も遅いものの順に、その終了時刻で゜ヌトされなければならず、最埌に、同䞀の終了時刻を持぀任意のキュヌは、最も叀いものの順に、それらがそれぞれのキュヌのテキストトラックリストに最埌に远加した順に゜ヌトされなければならない。たずえば、WebVTTファむル由来のキュヌに察しお、最初にファむルに蚘茉されおいた順でなど。[WEBVTT]

4.7.10.12.2 垯域内テキストトラックの情報源

メディアリ゜ヌス固有のテキストトラックはメディアリ゜ヌスで芋぀けられるデヌタに察応するテキストトラックである。

Rules for processing and rendering such data are defined by the relevant specifications, e.g. the specification of the video format if the media resource is a video.

When a media resource contains data that the user agent recognises and supports as being equivalent to a text track, the user agent runs the steps to expose a media-resource-specific text track with the relevant data, as follows.

  1. Associate the relevant data with a new text track and its corresponding new TextTrack object. The text track is a media-resource-specific text track.

  2. Set the new text track's kind, label, and language based on the semantics of the relevant data, as defined for the relevant format [INBANDTRACKS]. If there is no label in that data, then the label must be set to the empty string.

  3. Associate the text track list of cues with the rules for updating the text track rendering appropriate for the format in question.

  4. If the new text track's kind is metadata, then set the text track in-band metadata track dispatch type as follows, based on the type of the media resource:

    If the media resource is an Ogg file
    The text track in-band metadata track dispatch type must be set to the value of the Role header field. [OGGSKELETONHEADERS]
    If the media resource is a WebM file
    The text track in-band metadata track dispatch type must be set to the value of the CodecID element. [WEBMCG]
    If the media resource is an MPEG-2 file
    Let stream type be the value of the "stream_type" field describing the text track's type in the file's program map section, interpreted as an 8-bit unsigned integer. Let length be the value of the "ES_info_length" field for the track in the same part of the program map section, interpreted as an integer as defined by the MPEG-2 specification. Let descriptor bytes be the length bytes following the "ES_info_length" field. The text track in-band metadata track dispatch type must be set to the concatenation of the stream type byte and the zero or more descriptor bytes bytes, expressed in hexadecimal using uppercase ASCII hex digits. [MPEG2]
    If the media resource is an MPEG-4 file
    Let the first stsd box of the first stbl box of the first minf box of the first mdia box of the text track's trak box in the first moov box of the file be the stsd box, if any. If the file has no stsd box, or if the stsd box has neither a mett box nor a metx box, then the text track in-band metadata track dispatch type must be set to the empty string. Otherwise, if the stsd box has a mett box then the text track in-band metadata track dispatch type must be set to the concatenation of the string "mett", a U+0020 SPACE character, and the value of the first mime_format field of the first mett box of the stsd box, or the empty string if that field is absent in that box. Otherwise, if the stsd box has no mett box but has a metx box then the text track in-band metadata track dispatch type must be set to the concatenation of the string "metx", a U+0020 SPACE character, and the value of the first namespace field of the first metx box of the stsd box, or the empty string if that field is absent in that box. [MPEG4]
    If the media resource is a DASH media resource
    The text track in-band metadata track dispatch type must be set to the concatenation of the "AdaptationSet" element attributes and all child Role descriptors. [DASH]
  5. Populate the new text track's list of cues with the cues parsed so far, following the guidelines for exposing cues, and begin updating it dynamically as necessary.

  6. Set the new text track's readiness state to loaded.

  7. Set the new text track's mode to the mode consistent with the user's preferences and the requirements of the relevant specification for the data.

  8. Add the new text track to the media element's list of text tracks.

  9. Fire a trusted event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent interface, with the track attribute initialized to the text track's TextTrack object, at the media element's textTracks attribute's TextTrackList object.

4.7.10.12.3 Sourcing out-of-band text tracks

When a track element is created, it must be associated with a new text track (with its value set as defined below) and its corresponding new TextTrack object.

The text track kind is determined from the state of the element's kind attribute according to the following table; for a state given in a cell of the first column, the kind is the string given in the second column:

状態 String
Subtitles subtitles
Captions captions
抂芁 descriptions
Chapters chapters
Metadata metadata

The text track label is the element's track label.

The text track language is the element's track language, if any, or the empty string otherwise.

As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly, as per the definitions above.

Changes to the track URL are handled in the algorithm below.

The text track readiness state is initially not loaded, and the text track mode is initially disabled.

The text track list of cues is initially empty. It is dynamically modified when the referenced file is parsed. Associated with the list are the rules for updating the text track rendering appropriate for the format in question; for WebVTT, this is the rules for updating the display of WebVTT text tracks. [WEBVTT]

When a track element's parent element changes and the new parent is a media element, then the user agent must add the track element's corresponding text track to the media element's list of text tracks, and then queue a task to fire a trusted event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent interface, with the track attribute initialized to the text track's TextTrack object, at the media element's textTracks attribute's TextTrackList object.

When a track element's parent element changes and the old parent was a media element, then the user agent must remove the track element's corresponding text track from the media element's list of text tracks, and then queue a task to fire a trusted event with the name removetrack, that does not bubble and is not cancelable, and that uses the TrackEvent interface, with the track attribute initialized to the text track's TextTrack object, at the media element's textTracks attribute's TextTrackList object.


When a text track corresponding to a track element is added to a media element's list of text tracks, the user agent must queue a task to run the following steps for the media element:

  1. If the element's blocked-on-parser flag is true, abort these steps.

  2. If the element's did-perform-automatic-track-selection flag is true, abort these steps.

  3. Honor user preferences for automatic text track selection for this element.

When the user agent is required to honor user preferences for automatic text track selection for a media element, the user agent must run the following steps:

  1. Perform automatic text track selection for subtitles and captions.

  2. Perform automatic text track selection for descriptions.

  3. Perform automatic text track selection for chapters.

  4. If there are any text tracks in the media element's list of text tracks whose text track kind is metadata that correspond to track elements with a default attribute set whose text track mode is set to disabled, then set the text track mode of all such tracks to hidden

  5. Set the element's did-perform-automatic-track-selection flag to true.

When the steps above say to perform automatic text track selection for one or more text track kinds, it means to run the following steps:

  1. Let candidates be a list consisting of the text tracks in the media element's list of text tracks whose text track kind is one of the kinds that were passed to the algorithm, if any, in the order given in the list of text tracks.

  2. If candidates is empty, then abort these steps.

  3. If any of the text tracks in candidates have a text track mode set to showing, abort these steps.

  4. If the user has expressed an interest in having a track from candidates enabled based on its text track kind, text track language, and text track label, then set its text track mode to showing

    For example, the user could have set a browser preference to the effect of "I want French captions whenever possible", or "If there is a subtitle track with 'Commentary' in the title, enable it", or "If there are audio description tracks available, enable one, ideally in Swiss German, but failing that in Standard Swiss German or Standard German".

    Otherwise, if there are any text tracks in candidates that correspond to track elements with a default attribute set whose text track mode is set to disabled, then set the text track mode of the first such track to showing.

When a text track corresponding to a track element experiences any of the following circumstances, the user agent must start the track processing model for that text track and its track element:

When a user agent is to start the track processing model for a text track and its track element, it must run the following algorithm. This algorithm interacts closely with the event loop mechanism; in particular, it has a synchronous section (which is triggered as part of the event loop algorithm). The steps in that section are marked with ⌛.

  1. If another occurrence of this algorithm is already running for this text track and its track element, abort these steps, letting that other algorithm take care of this element.

  2. If the text track's text track mode is not set to one of hidden or showing, abort these steps.

  3. If the text track's track element does not have a media element as a parent, abort these steps.

  4. Run the remainder of these steps asynchronously, allowing whatever caused these steps to run to continue.

  5. Top: Await a stable state. The synchronous section consists of the following steps. (The steps in the synchronous section are marked with ⌛.)

  6. ⌛ Set the text track readiness state to loading.

  7. ⌛ Let URL be the track URL of the track element.

  8. ⌛ If the track element's parent is a media element then let CORS mode be the state of the parent media element's crossorigin content attribute. Otherwise, let CORS mode be No CORS.

  9. End the synchronous section, continuing the remaining steps asynchronously.

  10. If URL is not the empty string, perform a potentially CORS-enabled fetch of URL, with the mode being CORS mode, the origin being the origin of the track element's Document, and the default origin behaviour set to fail.

    The resource obtained in this fashion, if any, contains the text track data. If any data is obtained, it is by definition CORS-same-origin (cross-origin resources that are not suitably CORS-enabled do not get this far).

    The tasks queued by the fetching algorithm on the networking task source to process the data as it is being fetched must determine the type of the resource If the type of the resource is not a supported text track format, the load will fail, as described below. Otherwise, the resource's data must be passed to the appropriate parser (e.g. the WebVTT parser) as it is received, with the text track list of cues being used for that parser's output. [WEBVTT]

    The appropriate parser will synchronously (during these networking task source tasks) and incrementally (as each such task is run with whatever data has been received from the network) update the text track list of cues.

    This specification does not currently say whether or how to check the MIME types of text tracks, or whether or how to perform file type sniffing using the actual file data. Implementors differ in their intentions on this matter and it is therefore unclear what the right solution is. In the absence of any requirement here, the HTTP specification's strict requirement to follow the Content-Type header prevails ("Content-Type specifies the media type of the underlying data." ... "If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and./or the name extension(s) of the URI used to identify the resource.").

    If the fetching algorithm fails for any reason (network error, the server returns an error code, a cross-origin check fails, etc), if URL is the empty string, or if the type of the resource is not a supported text track format, then run these steps:

    1. Queue a task to first change the text track readiness state to failed to load and then fire a simple event named error at the track element.

    2. Wait until the text track readiness state is no longer set to loading.

    3. Wait until the track URL is no longer equal to URL, at the same time as the text track mode is set to hidden or showing.

    4. Jump to the step labeled top.

    If the fetching algorithm does not fail, then the final task that is queued by the networking task source must run the following steps after it has tried to parse the data:

    1. Change the text track readiness state to loaded.

    2. If the file was successfully processed, fire a simple event named load at the track element.

      Otherwise, the file was not successfully processed (e.g. the format in question is an XML format and the file contained a well-formedness error that the XML specification requires be detected and reported to the application); fire a simple event named error at the track element.

    3. Wait until the track URL is no longer equal to URL, at the same time as the text track mode is set to hidden or showing.

    4. Jump back to the step labeled top.

    If, while the fetching algorithm is active, either:

    ...then the user agent must run the following steps:

    1. Abort the fetching algorithm, discarding any pending tasks generated by that algorithm (and in particular, not adding any cues to the text track list of cues after the moment the URL changed).

    2. Jump back to the step labeled top.

    Until one of the above circumstances occurs, the user agent must remain on this step.

Whenever a track element has its src attribute set, changed, or removed, the user agent must synchronously empty the element's text track's text track list of cues. (This also causes the algorithm above to stop adding cues from the resource being obtained using the previously given URL, if any.)

4.7.10.12.4 Guidelines for exposing cues in various formats as text track cues

How a specific format's text track cues are to be interpreted for the purposes of processing by an HTML user agent is defined by that format [INBANDTRACKS]. In the absence of such a specification, this section provides some constraints within which implementations can attempt to consistently expose such formats.

To support the text track model of HTML, each unit of timed data is converted to a text track cue. Where the mapping of the format's features to the aspects of a text track cue as defined in this specification are not defined, implementations must ensure that the mapping is consistent with the definitions of the aspects of a text track cue as defined above, as well as with the following constraints:

The text track cue identifier

Should be set to the empty string if the format has no obvious analogue to a per-cue identifier.

The text track cue pause-on-exit flag

Should be set to false.

4.7.10.12.5 テキストトラックAPI
interface TextTrackList : EventTarget {
  readonly attribute unsigned long length;
  getter TextTrack (unsigned long index);
  TextTrack? getTrackById(DOMString id);

           attribute EventHandler onchange;
           attribute EventHandler onaddtrack;
           attribute EventHandler onremovetrack;
};
media . textTracks . length

メディア芁玠たずえばtrack芁玠からに関連付けられたテキストトラックの数を返す。これは、メディア芁玠のテキストトラックのリストでテキストトラックの数である。

media . textTracks[ n ]

メディア芁玠のテキストトラックのリストでn番目のテキストトラックを衚すTextTrackオブゞェクトを返す。

textTrack = media . textTracks . getTrackById( id )

䞎えられた識別子ずずもにTextTrackオブゞェクトを返す、たたは䞀切トラックがその識別子を持たない堎合nullを返す。

track . track

track芁玠のテキストトラックを衚すTextTrackオブゞェクトを返す。

A TextTrackList object represents a dynamically updating list of text tracks in a given order.

The textTracks attribute of media elements must return a TextTrackList object representing the TextTrack objects of the text tracks in the media element's list of text tracks, in the same order as in the list of text tracks. The same object must be returned each time the attribute is accessed. [WEBIDL]

The length attribute of a TextTrackList object must return the number of text tracks in the list represented by the TextTrackList object.

The supported property indices of a TextTrackList object at any instant are the numbers from zero to the number of text tracks in the list represented by the TextTrackList object minus one, if any. If there are no text tracks in the list, there are no supported property indices.

To determine the value of an indexed property of a TextTrackList object for a given index index, the user agent must return the indexth text track in the list represented by the TextTrackList object.

The getTrackById(id) method must return the first TextTrack in the TextTrackList object whose id IDL attribute would return a value equal to the value of the id argument. When no tracks match the given argument, the method must return null.


enum TextTrackMode { "disabled",  "hidden",  "showing" };
enum TextTrackKind { "subtitles",  "captions",  "descriptions",  "chapters",  "metadata" };
interface TextTrack : EventTarget {
  readonly attribute TextTrackKind kind;
  readonly attribute DOMString label;
  readonly attribute DOMString language;

  readonly attribute DOMString id;
  readonly attribute DOMString inBandMetadataTrackDispatchType;

           attribute TextTrackMode mode;

  readonly attribute TextTrackCueList? cues;
  readonly attribute TextTrackCueList? activeCues;

  void addCue(TextTrackCue cue);
  void removeCue(TextTrackCue cue);

           attribute EventHandler oncuechange;
};
textTrack = media . addTextTrack( kind [, label [, language ] ] )

メディア芁玠のテキストトラックのリストに远加された新しいTextTrackオブゞェクトを䜜成しお返す。

textTrack . kind

テキストトラックの皮類の文字列を返す。

textTrack . label

存圚する、たたは空の文字列オブゞェクトがナヌザヌに公開される堎合、オブゞェクトの他の属性からおそらく生成する必芁があるカスタムラベルを瀺すがある堎合、テキストトラックのラベルを返す。

textTrack . language

テキストトラックの蚀語の文字列を返す。

textTrack . id

指定されたトラックのIDを返す。

垯域内トラックに察しお、フォヌマットがMedia Fragments URI構文をサポヌトし、getTrackById()メ゜ッドずずもに䜿甚できる堎合、これは、フラグメント識別子で䜿甚できるIDである。[MEDIAFRAG]

track芁玠に察応するTextTrackオブゞェクトに察しお、これはtrack芁玠のIDである。

textTrack . inBandMetadataTrackDispatchType

テキストトラック垯域内のメタデヌタトラックディスパッチタむプの文字列を返す。

textTrack . mode [ = value ]

以䞋のリストから文字列によっお衚される、テキストトラックモヌドを返す

"disabled"

テキストトラック無効モヌド。

"hidden"

テキストトラック非衚瀺モヌド。

"showing"

テキストトラック衚瀺モヌド。

モヌドを倉曎する蚭定が可胜である。

textTrack . cues

TextTrackCueListオブゞェクトずしお、キュヌのテキストトラックリストを返す。

textTrack . activeCues

TextTrackCueListオブゞェクトずしお、珟圚アクティブであるキュヌのテキストトラックリストから、テキストトラックキュヌを返す぀たり、珟圚の再生䜍眮の前に開始し、その埌で終了する。

textTrack . addCue( cue )

textTrackのキュヌのテキストトラックリストに指定されたキュヌを远加する。

textTrack . removeCue( cue )

textTrackのキュヌのテキストトラックリストから指定されたキュヌを削陀する。

The addTextTrack(kind, label, language) method of media elements, when invoked, must run the following steps:

  1. Create a new TextTrack object.

  2. Create a new text track corresponding to the new object, and set its text track kind to kind, its text track label to label, its text track language to language, its text track readiness state to the text track loaded state, its text track mode to the text track hidden mode, and its text track list of cues to an empty list.

    Initially, the text track list of cues is not associated with any rules for updating the text track rendering. When a text track cue is added to it, the text track list of cues has its rules permanently set accordingly.

  3. Add the new text track to the media element's list of text tracks.

  4. Queue a task to fire a trusted event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent interface, with the track attribute initialized to the new text track's TextTrack object, at the media element's textTracks attribute's TextTrackList object.

  5. Return the new TextTrack object.


The kind attribute must return the text track kind of the text track that the TextTrack object represents.

The label attribute must return the text track label of the text track that the TextTrack object represents.

The language attribute must return the text track language of the text track that the TextTrack object represents.

The id attribute returns the track's identifier, if it has one, or the empty string otherwise. For tracks that correspond to track elements, the track's identifier is the value of the element's id attribute, if any. For in-band tracks, the track's identifier is specified by the media resource. If the media resource is in a format that supports the Media Fragments URI fragment identifier syntax, the identifier returned for a particular track must be the same identifier that would enable the track if used as the name of a track in the track dimension of such a fragment identifier. [MEDIAFRAG]

The inBandMetadataTrackDispatchType attribute must return the text track in-band metadata track dispatch type of the text track that the TextTrack object represents.

The mode attribute, on getting, must return the string corresponding to the text track mode of the text track that the TextTrack object represents, as defined by the following list:

"disabled"
テキストトラック無効モヌド。
"hidden"
テキストトラック非衚瀺モヌド。
"showing"
テキストトラック衚瀺モヌド。

On setting, if the new value isn't equal to what the attribute would currently return, the new value must be processed as follows:

If the new value is "disabled"

Set the text track mode of the text track that the TextTrack object represents to the text track disabled mode.

If the new value is "hidden"

Set the text track mode of the text track that the TextTrack object represents to the text track hidden mode.

If the new value is "showing"

Set the text track mode of the text track that the TextTrack object represents to the text track showing mode.

If the text track mode of the text track that the TextTrack object represents is not the text track disabled mode, then the cues attribute must return a live TextTrackCueList object that represents the subset of the text track list of cues of the text track that the TextTrack object represents whose end times occur at or after the earliest possible position when the script started, in text track cue order. Otherwise, it must return null. When an object is returned, the same object must be returned each time.

The earliest possible position when the script started is whatever the earliest possible position was the last time the event loop reached step 1.

If the text track mode of the text track that the TextTrack object represents is not the text track disabled mode, then the activeCues attribute must return a live TextTrackCueList object that represents the subset of the text track list of cues of the text track that the TextTrack object represents whose active flag was set when the script started, in text track cue order. Otherwise, it must return null. When an object is returned, the same object must be returned each time.

A text track cue's active flag was set when the script started if its text track cue active flag was set the last time the event loop reached step 1.


The addCue(cue) method of TextTrack objects, when invoked, must run the following steps:

  1. If the text track list of cues does not yet have any associated rules for updating the text track rendering, then associate the text track list of cues with the rules for updating the text track rendering appropriate to cue.

  2. If text track list of cues' associated rules for updating the text track rendering are not the same rules for updating the text track rendering as appropriate for cue, then throw an InvalidStateError exception and abort these steps.

  3. If the given cue is in a text track list of cues, then remove cue from that text track list of cues.

  4. Add cue to the method's TextTrack object's text track's text track list of cues.

The removeCue(cue) method of TextTrack objects, when invoked, must run the following steps:

  1. If the given cue is not currently listed in the method's TextTrack object's text track's text track list of cues, then throw a NotFoundError exception and abort these steps.

  2. Remove cue from the method's TextTrack object's text track's text track list of cues.

この䟋においお、audio芁玠は、倚数のサりンド゚フェクトを含むサりンドファむルから特定のサりンド゚フェクトを再生するために䜿甚される。キュヌは、たずえブラりザが䞀郚のスクリプトを実行しおビゞヌであっおも、オヌディオがクリップの最埌で正確に終了するよう、オヌディオを䞀時停止するために䜿甚される。ペヌゞがオヌディオを䞀時停止するスクリプトに䟝存し、ブラりザは指定された正確な時間にスクリプトを実行するこずができなかった堎合、次のクリップの出だしを聞いおいるかもしれない。

var sfx = new Audio('sfx.wav');
var sounds = sfx.addTextTrack('metadata');

// add sounds we care about
function addFX(start, end, name) {
  var cue = new VTTCue(start, end, '');
  cue.id = name;
  cue.pauseOnExit = true;
  sounds.addCue(cue);
}
addFX(12.783, 13.612, 'dog bark');
addFX(13.612, 15.091, 'kitten mew'))

function playSound(id) {
  sfx.currentTime = sounds.getCueById(id).startTime;
  sfx.play();
}

// play a bark as soon as we can
sfx.oncanplaythrough = function () {
  playSound('dog bark');
}
// meow when the user tries to leave
window.onbeforeunload = function () {
  playSound('kitten mew');
  return 'Are you sure you want to leave this awesome page?';
}

interface TextTrackCueList {
  readonly attribute unsigned long length;
  getter TextTrackCue (unsigned long index);
  TextTrackCue? getCueById(DOMString id);
};
cuelist . length

リスト内のキュヌの数を返す。

cuelist[index]

リスト内のむンデックスindexを持぀テキストトラックキュヌを返す。キュヌは、テキストトラックキュヌ順に゜ヌトされる。

cuelist . getCueById( id )

テキストトラックキュヌ識別子idを持぀テキストトラックキュヌ順で最初のテキストトラックキュヌを返す。

いずれのキュヌも指定された識別子を持たない堎合、たたは匕数が空の文字列である堎合、nullを返す。

A TextTrackCueList object represents a dynamically updating list of text track cues in a given order.

The length attribute must return the number of cues in the list represented by the TextTrackCueList object.

The supported property indices of a TextTrackCueList object at any instant are the numbers from zero to the number of cues in the list represented by the TextTrackCueList object minus one, if any. If there are no cues in the list, there are no supported property indices.

To determine the value of an indexed property for a given index index, the user agent must return the indexth text track cue in the list represented by the TextTrackCueList object.

The getCueById(id) method, when called with an argument other than the empty string, must return the first text track cue in the list represented by the TextTrackCueList object whose text track cue identifier is id, if any, or null otherwise. If the argument is the empty string, then the method must return null.


interface TextTrackCue : EventTarget {
  readonly attribute TextTrack? track;

           attribute DOMString id;
           attribute double startTime;
           attribute double endTime;
           attribute boolean pauseOnExit;

           attribute EventHandler onenter;
           attribute EventHandler onexit;
};
cue . track

存圚する堎合、このテキストトラックキュヌが属するTextTrackオブゞェクトを返し、そうでなければnullを返す。

cue . id [ = value ]

テキストトラックキュヌ識別子を返す。

蚭定可胜である。

cue . startTime [ = value ]

秒単䜍で、テキストトラックキュヌの開始時刻を返す。

蚭定可胜である。

cue . endTime [ = value ]

秒単䜍で、テキストトラックキュヌの終了時刻を返す。

蚭定可胜である。

cue . pauseOnExit [ = value ]

テキスト·トラック·キュヌpause-on-exitフラグが蚭定される堎合trueを返し、そうでなければfalseを返す。

蚭定可胜である。

The track attribute, on getting, must return the TextTrack object of the text track in whose list of cues the text track cue that the TextTrackCue object represents finds itself, if any; or null otherwise.

The id attribute, on getting, must return the text track cue identifier of the text track cue that the TextTrackCue object represents. On setting, the text track cue identifier must be set to the new value.

The startTime attribute, on getting, must return the text track cue start time of the text track cue that the TextTrackCue object represents, in seconds. On setting, the text track cue start time must be set to the new value, interpreted in seconds; then, if the TextTrackCue object's text track cue is in a text track's list of cues, and that text track is in a media element's list of text tracks, and the media element's show poster flag is not set, then run the time marches on steps for that media element.

The endTime attribute, on getting, must return the text track cue end time of the text track cue that the TextTrackCue object represents, in seconds. On setting, the text track cue end time must be set to the new value, interpreted in seconds; then, if the TextTrackCue object's text track cue is in a text track's list of cues, and that text track is in a media element's list of text tracks, and the media element's show poster flag is not set, then run the time marches on steps for that media element.

The pauseOnExit attribute, on getting, must return true if the text track cue pause-on-exit flag of the text track cue that the TextTrackCue object represents is set; or false otherwise. On setting, the text track cue pause-on-exit flag must be set if the new value is true, and must be unset otherwise.

4.7.10.12.6 章を蚘述するテキストトラック

章は、指定されたタむトルをも぀メディアリ゜ヌスの区分である。文曞アりトラむンのセクションでサブセクションを持぀こずができるのず同じように、章は入れ子にできる。

章を蚘述するために䜿甚されおいるテキストトラック内の各テキストトラックキュヌは、章の開始時刻を䞎えるテキストトラックキュヌの開始時刻、章の終了時刻を䞎えるテキストトラックキュヌの終了時刻、および章のタむトルを䞎えるテキストトラックキュヌのテキストの3぀の䞻芁な機胜を持぀。

The rules for constructing the chapter tree from a text track are as follows. They produce a potentially nested list of chapters, each of which have a start time, end time, title, and a list of nested chapters. This algorithm discards cues that do not correctly nest within each other, or that are out of order.

  1. Let list be a copy of the list of cues of the text track being processed.

  2. Remove from list any text track cue whose text track cue end time is before its text track cue start time.

  3. Let output be an empty list of chapters, where a chapter is a record consisting of a start time, an end time, a title, and a (potentially empty) list of nested chapters. For the purpose of this algorithm, each chapter also has a parent chapter.

  4. Let current chapter be a stand-in chapter whose start time is negative infinity, whose end time is positive infinity, and whose list of nested chapters is output. (This is just used to make the algorithm easier to describe.)

  5. Loop: If list is empty, jump to the step labeled end.

  6. Let current cue be the first cue in list, and then remove it from list.

  7. If current cue's text track cue start time is less than the start time of current chapter, then return to the step labeled loop.

  8. While current cue's text track cue start time is greater than or equal to current chapter's end time, let current chapter be current chapter's parent chapter.

  9. If current cue's text track cue end time is greater than the end time of current chapter, then return to the step labeled loop.

  10. Create a new chapter new chapter, whose start time is current cue's text track cue start time, whose end time is current cue's text track cue end time, whose title is current cue's text track cue data interpreted according to its rules for rendering the cue in isolation, and whose list of nested chapters is empty.

    For WebVTT, the rules for rendering the cue in isolation are the rules for interpreting WebVTT cue text. [WEBVTT]

  11. Append new chapter to current chapter's list of nested chapters, and let current chapter be new chapter's parent.

  12. Let current chapter be new chapter.

  13. Return to the step labeled loop.

  14. End: Return output.

WebVTTファむルの以䞋の断片は、ネストされた章をマヌクアップする様子を瀺す。ファむルは、3぀の50分の章、"Astrophysics"、"Computational Physics"、および"General Relativity"を蚘述する。1぀目は3぀のサブチャプタヌを持ち、2぀目は4぀、3぀目は2぀のサブチャプタヌを持぀。[WEBVTT]

WEBVTT

00:00:00.000 --> 00:50:00.000
Astrophysics

00:00:00.000 --> 00:10:00.000
Introduction to Astrophysics

00:10:00.000 --> 00:45:00.000
The Solar System

00:00:00.000 --> 00:10:00.000
Coursework Description

00:50:00.000 --> 01:40:00.000
Computational Physics

00:50:00.000 --> 00:55:00.000
Introduction to Programming

00:55:00.000 --> 01:30:00.000
Data Structures

01:30:00.000 --> 01:35:00.000
Answers to Last Exam

01:35:00.000 --> 01:40:00.000
Coursework Description

01:40:00.000 --> 02:30:00.000
General Relativity

01:40:00.000 --> 02:00:00.000
Tensor Algebra

02:00:00.000 --> 02:30:00.000
The General Relativistic Field Equations
4.7.10.12.7 Event definitions

The following are the event handlers that (and their corresponding event handler event types) must be supported, as event handler IDL attributes, by all objects implementing the TextTrackList interface:

むベントハンドラ むベントハンドラむベント型
onchange change
onaddtrack addtrack
onremovetrack removetrack

The following are the event handlers that (and their corresponding event handler event types) must be supported, as event handler IDL attributes, by all objects implementing the TextTrack interface:

むベントハンドラ むベントハンドラむベント型
oncuechange cuechange

The following are the event handlers that (and their corresponding event handler event types) must be supported, as event handler IDL attributes, by all objects implementing the TextTrackCue interface:

むベントハンドラ むベントハンドラむベント型
onenter enter
onexit exit
4.7.10.13 ナヌザヌむンタヌフェヌス

controls属性は真停属性である。存圚する堎合、著者がスクリプト化されたコントロヌラを提䟛しおおらず、ナヌザヌ゚ヌゞェントに独自のコントロヌルセットを提䟛したいず考えおいるこずを瀺す。

If the attribute is present, or if scripting is disabled for the media element, then the user agent should expose a user interface to the user. This user interface should include features to begin playback, pause playback, seek to an arbitrary position in the content (if the content supports arbitrary seeking), change the volume, change the display of closed captions or embedded sign-language tracks, select different audio tracks or turn on audio descriptions, and show the media content in manners more suitable to the user (e.g. full-screen video or in an independent resizable window). Other controls may also be made available.

If the media element has a current media controller, then the user agent should expose audio tracks from all the slaved media elements (although avoiding duplicates if the same media resource is being used several times). If a media resource's audio track exposed in this way has no known name, and it is the only audio track for a particular media element, the user agent should use the element's title attribute, if any, as the name (or as part of the name) of that track.

Even when the attribute is absent, however, user agents may provide controls to affect playback of the media resource (e.g. play, pause, seeking, and volume controls), but such features should not interfere with the page's normal rendering. For example, such features could be exposed in the media element's context menu. The user agent may implement this simply by exposing a user interface to the user as described above (as if the controls attribute was present).

If the user agent exposes a user interface to the user by displaying controls over the media element, then the user agent should suppress any user interaction events while the user agent is interacting with this interface. (For example, if the user clicks on a video's playback control, mousedown events and so forth would not simultaneously be fired at elements on the page.)

Where possible (specifically, for starting, stopping, pausing, and unpausing playback, for seeking, for changing the rate of playback, for fast-forwarding or rewinding, for listing, enabling, and disabling text tracks, and for muting or changing the volume of the audio), user interface features exposed by the user agent must be implemented in terms of the DOM API described above, so that, e.g., all the same events fire.

When a media element has a current media controller, the user agent's user interface for pausing and unpausing playback, for seeking, for changing the rate of playback, for fast-forwarding or rewinding, and for muting or changing the volume of audio of the entire group must be implemented in terms of the MediaController API exposed on that current media controller. When a media element has a current media controller, and all the slaved media elements of that MediaController are paused, the user agent should also unpause all the slaved media elements when the user invokes a user agent interface control for beginning playback.

The "play" function in the user agent's interface must set the playbackRate attribute to the value of the defaultPlaybackRate attribute before invoking the play() method. When a media element has a current media controller, the attributes and method with those names on that MediaController object must be used. Otherwise, the attributes and method with those names on the media element itself must be used.

Features such as fast-forward or rewind must be implemented by only changing the playbackRate attribute (and not the defaultPlaybackRate attribute). Again, when a media element has a current media controller, the attributes with those names on that MediaController object must be used; otherwise, the attributes with those names on the media element itself must be used.

When a media element has a current media controller, seeking must be implemented in terms of the currentTime attribute on that MediaController object. Otherwise, the user agent must directly seek to the requested position in the media element's media timeline. For media resources where seeking to an arbitrary position would be slow, user agents are encouraged to use the approximate-for-speed flag when seeking in response to the user manipulating an approximate position interface such as a seek bar.

When a media element has a current media controller, user agents may additionally provide the user with controls that directly manipulate an individual media element without affecting the MediaController, but such features are considered relatively advanced and unlikely to be useful to most users.

The activation behavior of a media element that is exposing a user interface to the user must be to run the following steps:

  1. If the media element has a current media controller, and that current media controller is a restrained media controller, then invoke the play() method of the MediaController.

  2. Otherwise, if the media element has a current media controller, and that current media controller is a paused media controller, then invoke the unpause() method of the MediaController.

  3. Otherwise, if the media element has a current media controller, then that current media controller is a playing media controller; invoke the pause() method of the MediaController.

  4. Otherwise, the media element has no current media controller; if the media element's paused attribute is true, then invoke the play() method on the media element.

  5. Otherwise, the media element has no current media controller, and the media element's paused attribute is false; invoke the pause() method on the media element.

For the purposes of listing chapters in the media resource, only text tracks in the media element's list of text tracks that are showing and whose text track kind is chapters should be used. Such tracks must be interpreted according to the rules for constructing the chapter tree from a text track. When seeking in response to a user maniplating a chapter selection interface, user agents should not use the approximate-for-speed flag.

The controls IDL attribute must reflect the content attribute of the same name.


media . volume [ = value ]

0.0から1.0たでの範囲の数字ずしお、珟圚の再生音量を返す。ここで0.0は最小音量で1.0は最倧音量である。

音量を倉曎する蚭定が可胜である。

新しい倀が範囲0.0から1.0に含たれない堎合、IndexSizeErrorを投げる。

media . muted [ = value ]

volume属性を䞊曞きし、音声がミュヌトである堎合trueを返し、volume属性が無芖される堎合、falseを返す。

オヌディオがミュヌトであるかどうかを倉曎する蚭定が可胜である。

The volume attribute must return the playback volume of any audio portions of the media element, in the range 0.0 (silent) to 1.0 (loudest). Initially, the volume should be 1.0, but user agents may remember the last set value across sessions, on a per-site basis or otherwise, so the volume may start at other values. On setting, if the new value is in the range 0.0 to 1.0 inclusive, the playback volume of any audio portions of the media element must be set to the new value. If the new value is outside the range 0.0 to 1.0 inclusive, then, on setting, an IndexSizeError exception must be thrown instead.

The muted attribute must return true if the audio output is muted and false otherwise. Initially, the audio output should not be muted (false), but user agents may remember the last set value across sessions, on a per-site basis or otherwise, so the muted state may start as muted (true). On setting, if the new value is true then the audio output should be muted and if the new value is false it should be unmuted.

Whenever either of the values that would be returned by the volume and muted attributes change, the user agent must queue a task to fire a simple event named volumechange at the media element.

An element's effective media volume is determined as follows:

  1. If the user has indicated that the user agent is to override the volume of the element, then the element's effective media volume is the volume desired by the user. Abort these steps.

  2. If the element's audio output is muted, the element's effective media volume is zero. Abort these steps.

  3. If the element has a current media controller and that MediaController object's media controller mute override is true, the element's effective media volume is zero. Abort these steps.

  4. Let volume be the playback volume of the audio portions of the media element, in range 0.0 (silent) to 1.0 (loudest).

  5. If the element has a current media controller, multiply volume by that MediaController object's media controller volume multiplier.

  6. The element's effective media volume is volume, interpreted relative to the range 0.0 to 1.0, with 0.0 being silent, and 1.0 being the loudest setting, values in between increasing in loudness. The range need not be linear. The loudest setting may be lower than the system's loudest possible setting; for example the user could have set a maximum volume.

メディア芁玠のmuted属性は、朜圚的にナヌザヌ蚭定を䞊曞きし、メディアリ゜ヌスに属するオヌディオ出力のデフォルトの状態を制埡する真停属性である。

When a media element is created, if it has a muted attribute specified, the user agent must mute the media element's audio output, overriding any user preference.

The defaultMuted IDL attribute must reflect the muted content attribute.

この属性は動的効果芁玠のデフォルトの状態のみを制埡するを持たない。

このビデオ広告は自動再生するが、ナヌザヌを悩たすのを避けるために音なしで再生しお、ナヌザヌが音声をオンにできるようにする。

<video src="adverts.cgi?kind=video" controls autoplay loop muted></video>
4.7.10.14 時間範囲

TimeRangesむンタヌフェヌスを実装したオブゞェクトは、時間の範囲期間のリストを衚す。

interface TimeRanges {
  readonly attribute unsigned long length;
  double start(unsigned long index);
  double end(unsigned long index);
};
media . length

オブゞェクト内の範囲の数を返す。

time = media . start(index)

指定されたむンデックスをも぀範囲の開始時刻を返す。

むンデックスが範囲倖の堎合IndexSizeErrorを投げる。

time = media . end(index)

指定されたむンデックスをも぀範囲の終了時刻を返す。

むンデックスが範囲倖の堎合IndexSizeErrorを投げる。

The length IDL attribute must return the number of ranges represented by the object.

The start(index) method must return the position of the start of the indexth range represented by the object, in seconds measured from the start of the timeline that the object covers.

The end(index) method must return the position of the end of the indexth range represented by the object, in seconds measured from the start of the timeline that the object covers.

These methods must throw IndexSizeError exceptions if called with an index argument greater than or equal to the number of ranges represented by the object.

When a TimeRanges object is said to be a normalized TimeRanges object, the ranges it represents must obey the following criteria:

In other words, the ranges in such an object are ordered, don't overlap, aren't empty, and don't touch (adjacent ranges are folded into one bigger range).

Ranges in a TimeRanges object must be inclusive.

Thus, the end of a range would be equal to the start of a following adjacent (touching but not overlapping) range. Similarly, a range covering a whole timeline anchored at zero would have a start equal to zero and an end equal to the duration of the timeline.

The timelines used by the objects returned by the buffered, seekable and played IDL attributes of media elements must be that element's media timeline.

4.7.10.15 むベント定矩
[Constructor(DOMString type, optional TrackEventInit eventInitDict)]
interface TrackEvent : Event {
  readonly attribute (VideoTrack or AudioTrack or TextTrack) track;
};

dictionary TrackEventInit : EventInit {
  (VideoTrack or AudioTrack or TextTrack) track;
};
event . track

むベントが関連するトラックオブゞェクトTextTrack、AudioTrack、たたはVideoTrackを返す。

The track attribute must return the value it was initialized to. オブゞェクトが䜜成される際、この属性はnullに初期化しなければならない。It represents the context information for the event.

4.7.10.16 むベントの抂芁

この節は非芏範的である。

䞊蚘の凊理モデルの䞀郚ずしお、メディア芁玠で以䞋のむベントが発火する

むベント名 むンタヌフェヌス 発火条件 Preconditions
loadstart Event ナヌザヌ゚ヌゞェントは、リ゜ヌス遞択アルゎリズムの䞀郚ずしお、メディアデヌタを探し始める。 networkStateがNETWORK_LOADINGず等しい
progress Event ナヌザヌ゚ヌゞェントは、メディアデヌタをフェッチしおいる。 networkStateがNETWORK_LOADINGず等しい
suspend Event ナヌザヌ゚ヌゞェントは、意図的に珟圚のメディアデヌタをフェッチしおいない。 networkStateはNETWORK_IDLEず等しい
abort Event ナヌザヌ゚ヌゞェントは、完党にダりンロヌドされる前にメディアデヌタのフェッチを停止するが、゚ラヌによるものではない。 errorは、コヌドMEDIA_ERR_ABORTEDをも぀オブゞェクトである。 networkStateは、ダりンロヌドが䞭止された時期に応じお、NETWORK_EMPTYたたはNETWORK_IDLEのいずれかに等しい。
error Event メディアデヌタのフェッチ䞭に゚ラヌが発生する。 errorは、コヌドMEDIA_ERR_NETWORK以䞊をも぀オブゞェクトである。 networkStateは、ダりンロヌドが䞭止された時期に応じお、NETWORK_EMPTYたたはNETWORK_IDLEのいずれかに等しい。
emptied Event 以前NETWORK_EMPTY状態でなかったnetworkStateであるメディア芁玠が、その状態にちょうど切り替わったロヌド䞭に臎呜的な゚ラヌが発生したため、リ゜ヌス遞択アルゎリズムがすでに実行しおいる間にload()メ゜ッドが呌び出されたためのいずれか。 networkStateはNETWORK_EMPTYであり、すべおのIDL属性は、初期状態である。
stalled Event ナヌザヌ゚ヌゞェントは、メディアデヌタをフェッチしようずしおいるが、デヌタが突発的に甚意されない。 networkStateはNETWORK_LOADINGである。
loadedmetadata Event ナヌザヌ゚ヌゞェントは、ちょうどメディアリ゜ヌスずテキストトラックの準備の期間ず寞法を決定した。 readyStateは初期時間に察しお新たにHAVE_METADATAに等しいかそれ以䞊である。
loadeddata Event ナヌザヌ゚ヌゞェントは、初期時間に察しお珟圚の再生䜍眮でメディアデヌタをレンダリングできる。 readyStateは、初期時間に察しお新たにHAVE_CURRENT_DATA以䞊に増加した。
canplay Event ナヌザヌ゚ヌゞェントは、メディアデヌタの再生を再開できるが、再生を今すぐ開始されるこずになったかどうかを掚定し、メディアリ゜ヌスは、コンテンツの远加のバッファリングに察しお停止させるこずなく、終わりに珟圚の再生レヌトでレンダリングできなかった。 readyStateは、新たにHAVE_FUTURE_DATA以䞊に増加した。
canplaythrough Event ナヌザヌ゚ヌゞェントは、再生が今すぐ開始されるこずになったかどうかを掚定し、メディアリ゜ヌスは远加のバッファリングに察しお停止するこずなく、珟圚の再生レヌトの最埌たでのすべおの方法でレンダリングできる。 readyStateは最近のHAVE_ENOUGH_DATAに等しい。
playing Event 再生は、メディアデヌタの䞍足のために、䞀時停止たたは遅延された埌に開始する準備ができおいる。 readyStateが新たに等しいたたはHAVE_FUTURE_DATAを超えおおり、pausedはfalseであり、たたはpausedが新たにfalseであり、readyStateが等しいか、たたはHAVE_FUTURE_DATAより倧きい。たずえこのむベントが発火しおも、 芁玠は䟝然ずしお朜圚的に再生されおいないかもしれない。たずえば、芁玠がメディアコントロヌラ䞊でブロックされる堎合たずえば、珟圚のメディアコントロヌラが䞀時停止するか、たたは別の埓属メディア芁玠が䜕らかの圢でストヌルしおいるため、たたはメディアリ゜ヌスがメディアコントロヌラの䜍眮に察応するデヌタがないため、たたは芁玠がナヌザヌずの察話のために䞀時停止たたは垯域内コンテンツのために䞀時停止である。
waiting Event 次のフレヌムが利甚できないため、再生が停止したが、ナヌザヌ゚ヌゞェントは、そのフレヌムがやがお利甚できるようになるず予想する。 readyStateが等しいか、たたはHAVE_CURRENT_DATA未満であり、pausedはfalseである。seekingはtrueである、たたは珟圚の再生䜍眮はbuffered内の領域のいずれかに含たれおいないかのいずれか。再生がpausedがfalseでなしにその他の理由で停止するこずは可胜であるが、それらの理由はこのむベントは発火しないそしおそのような状況が解決するずきに、別々のplayingむベントがどちらか発火しないたずえば、芁玠が新たにそのメディアコントロヌラ䞊でブロックされる、再生が終了する、たたは再生が゚ラヌにより停止され、たたは芁玠がナヌザヌずの察話のために䞀時停止たたは垯域内コンテンツのために䞀時停止しおいる。
seeking Event seekingIDL属性がtrueに倉曎され、か぀ナヌザヌ゚ヌゞェントが新しい䜍眮を探し始めおいる。
seeked Event current playback positionが倉曎された埌に、seekingIDL属性がfalseに倉曎された。
ended Event メディアリ゜ヌスの終わりに達したため、再生が停止した。 currentTimeは、メディアリ゜ヌスの最埌に等しく、endedはtrueである。
durationchange Event duration属性はちょうど曎新された。
timeupdate Event 珟圚の再生䜍眮が、通垞の再生の䞀郚ずしお、たたは、たずえば䞍連続的に、特に興味深い方法で倉曎された。
play Event 芁玠はもはや䞀時停止でない。play()メ゜ッドが返された埌、たたはautoplay属性を開始する再生を起こす際に発火した。 pausedは、新たにfalseである。
pause Event 芁玠が䞀時停止された。pause()メ゜ッドが返された埌に発火した。 pausedは、新たにtrueである。
ratechange Event defaultPlaybackRateたたは playbackRate属性が曎新されたばかりのいずれか。
resize Event videoWidthずvideoWidth属性のいずれかたたは䞡方がちょうど曎新されおいる。 メディア芁玠はvideo芁玠である。readyStateはHAVE_NOTHINGでない。
volumechange Event volume属性たたはmuted属性のいずれかが倉曎された。関連する属性のセッタヌが返された埌に発火した。

MediaControllerオブゞェクトで次のむベントが発火する

むベント名 むンタヌフェヌス 発火条件
emptied Event すべおの埓属メディア芁玠は、新たにHAVE_NOTHING以䞊に蚭定したreadyStateをも぀か、たたは埓属メディア芁玠がもはや存圚しない。
loadedmetadata Event すべおの埓属メディア芁玠のreadyStateが新たHAVE_METADATA以䞊に蚭定される。
loadeddata Event すべおの埓属メディア芁玠のreadyStateが新たHAVE_CURRENT_DATA以䞊に蚭定される。
canplay Event すべおの埓属メディア芁玠のreadyStateが新たHAVE_FUTURE_DATA以䞊に蚭定される。
canplaythrough Event すべおの埓属メディア芁玠のreadyStateが新たHAVE_ENOUGH_DATA以䞊に蚭定される。
playing Event MediaControllerは、もはやブロックメディアコントロヌラではない。
ended Event MediaControllerは、すべおの埓属メディア芁玠の終わりに達した。
waiting Event MediaControllerは珟圚、ブロックされたメディアコントロヌラである。
ended Event すべおの埓属メディア芁玠が新たに再生を終了しおいる。
durationchange Event duration属性はちょうど曎新された。
timeupdate Event メディアコントロヌラの䜍眮が倉曎された。
play Event paused属性が新たにfalseである。
pause Event paused属性が新たにtrueである。
ratechange Event defaultPlaybackRate属性たたはplaybackRate属性がちょうど曎新されたかのいずれか。
volumechange Event volume属性たたはmuted属性がちょうど曎新されたかのいずれか。

AudioTrackList、VideoTrackList、およびTextTrackList オブゞェクトで次のむベントが発火する

むベント名 むンタヌフェヌス 発火条件
change Event トラックリストの1぀以䞊のトラックが有効か無効を持っおいる。
addtrack TrackEvent トラックはトラックリストに加えられおいる。
removetrack TrackEvent トラックはトラックリストから削陀されおいる。
4.7.10.17 Security and privacy considerations

The main security and privacy implications of the video and audio elements come from the ability to embed media cross-origin. There are two directions that threats can flow: from hostile content to a victim page, and from a hostile page to victim content.


If a victim page embeds hostile content, the threat is that the content might contain scripted code that attempts to interact with the Document that embeds the content. To avoid this, user agents must ensure that there is no access from the content to the embedding page. In the case of media content that uses DOM concepts, the embedded content must be treated as if it was in its own unrelated top-level browsing context.

For instance, if an SVG animation was embedded in a video element, the user agent would not give it access to the DOM of the outer page. From the perspective of scripts in the SVG resource, the SVG file would appear to be in a lone top-level browsing context with no parent.


If a hostile page embeds victim content, the threat is that the embedding page could obtain information from the content that it would not otherwise have access to. The API does expose some information: the existence of the media, its type, its duration, its size, and the performance characteristics of its host. Such information is already potentially problematic, but in practice the same information can more or less be obtained using the img element, and so it has been deemed acceptable.

However, significantly more sensitive information could be obtained if the user agent further exposes metadata within the content such as subtitles or chapter titles. Such information is therefore only exposed if the video resource passes a CORS resource sharing check. The crossorigin attribute allows authors to control how this check is performed. [CORS]

Without this restriction, an attacker could trick a user running within a corporate network into visiting a site that attempts to load a video from a previously leaked location on the corporation's intranet. If such a video included confidential plans for a new product, then being able to read the subtitles would present a serious confidentiality breach.

4.7.10.18 メディア芁玠を䜿甚する著者に察するベストプラクティス

この節は非芏範的である。

セットトップボックスや携垯電話などの小型機噚䞊でオヌディオおよびビデオを再生するリ゜ヌスは倚くの堎合、限られたデバむスのハヌドりェアリ゜ヌスによっお制限される。たずえば、デバむスは3぀の䞀斉ビデオのみをサポヌトするかもしれない。このような理由から、芁玠ぞの参照をすべお削陀するこずに関しお非垞に慎重であり、か぀ガヌベゞコレクションするこずによっお、たたは芁玠のsrc属性ず任意のsource芁玠の子孫を削陀しおから、芁玠のload()メ゜ッドを呌び出こずによっおのいずれかで、それらが再生し終わった際、メディア芁玠が保持するリ゜ヌスを解攟するこずを掚奚する。

同様に、再生速床が正確に1.0でない堎合、ハヌドりェア、゜フトりェア、たたはフォヌマットの制限はビデオフレヌムに欠萜や、オヌディオに音途切れや無音をもたらすかもしれない。

4.7.10.19 メディア芁玠を䜿甚する著者に察するベストプラクティス

この節は非芏範的である。

How accurately various aspects of the media element API are implemented is considered a quality-of-implementation issue.

For example, when implementing the buffered attribute, how precise an implementation reports the ranges that have been buffered depends on how carefully the user agent inspects the data. Since the API reports ranges as times, but the data is obtained in byte streams, a user agent receiving a variable-bit-rate stream might only be able to determine precise times by actually decoding all of the data. User agents aren't required to do this, however; they can instead return estimates (e.g. based on the average bit rate seen so far) which get revised as more information becomes available.

As a general rule, user agents are urged to be conservative rather than optimistic. For example, it would be bad to report that everything had been buffered when it had not.

Another quality-of-implementation issue would be playing a video backwards when the codec is designed only for forward playback (e.g. there aren't many key frames, and they are far apart, and the intervening frames only have deltas from the previous frame). User agents could do a poor job, e.g. only showing key frames; however, better implementations would do more work and thus do a better job, e.g. actually decoding parts of the video forwards, storing the complete frames, and then playing the frames backwards.

Similarly, while implementations are allowed to drop buffered data at any time (there is no requirement that a user agent keep all the media data obtained for the lifetime of the media element), it is again a quality of implementation issue: user agents with sufficient resources to keep all the data around are encouraged to do so, as this allows for a better user experience. For example, if the user is watching a live stream, a user agent could allow the user only to view the live video; however, a better user agent would buffer everything and allow the user to seek through the earlier material, pause it, play it forwards and backwards, etc.

When multiple tracks are synchronised with a MediaController, it is possible for scripts to add and remove media elements from the MediaController's list of slaved media elements, even while these tracks are playing. How smoothly the media plays back in such situations is another quality-of-implementation issue.


When a media element that is paused is removed from a document and not reinserted before the next time the event loop spins, implementations that are resource constrained are encouraged to take that opportunity to release all hardware resources (like video planes, networking resources, and data buffers) used by the media element. (User agents still have to keep track of the playback position and so forth, though, in case playback is later restarted.)

4.7.11 map芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
透過的。
コンテンツ属性
グロヌバル属性
name - usemap属性から参照するむメヌゞマップ名
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLMapElement : HTMLElement {
           attribute DOMString name;
  readonly attribute HTMLCollection areas;
  readonly attribute HTMLCollection images;
};

map芁玠は、img芁玠および任意のarea芁玠の子孫ず連動しお、むメヌゞマップを定矩する。芁玠は、その子を衚す。

name属性は、マップを参照できるようマップに名前を䞎える。属性は存圚しなければならず、空癜文字なしで非空癜の倀を持たなければならない。name属性の倀は、同じ文曞で別のmap芁玠のname属性倀ずマッチする互換性倧文字・小文字䞍区別であっおはならない。id属性がたた指定される堎合、䞡方の属性が同じ倀を持たなければならない。

map . areas

mapのarea芁玠のHTMLCollectionを返す。

map . images

mapを䜿甚するimgおよびobject芁玠のHTMLCollectionを返す。

The areas attribute must return an HTMLCollection rooted at the map element, whose filter matches only area elements.

The images attribute must return an HTMLCollection rooted at the Document node, whose filter matches only img and object elements that are associated with this map element according to the image map processing model.

The IDL attribute name must reflect the content attribute of the same name.

むメヌゞマップは、メンテナンスを容易にするために、ペヌゞ䞊の他のコンテンツず組み合わせお定矩できる。この䟋は、ペヌゞの䞊郚に、むメヌゞマップず䞋郚のテキストリンクの察応するセットを䜿甚したペヌゞである。

<!DOCTYPE HTML>
<TITLE>Babies™: Toys</TITLE>
<HEADER>
 <H1>Toys</H1>
 <IMG SRC="/images/menu.gif"
      ALT="Babies™ navigation menu. Select a department to go to its page."
      USEMAP="#NAV">
</HEADER>
 ...
<FOOTER>
 <MAP NAME="NAV">
  <P>
   <A HREF="/clothes/">Clothes</A>
   <AREA ALT="Clothes" COORDS="0,0,100,50" HREF="/clothes/"> |
   <A HREF="/toys/">Toys</A>
   <AREA ALT="Toys" COORDS="0,0,100,50" HREF="/toys/"> |
   <A HREF="/food/">Food</A>
   <AREA ALT="Food" COORDS="0,0,100,50" HREF="/food/"> |
   <A HREF="/books/">Books</A>
   <AREA ALT="Books" COORDS="0,0,100,50" HREF="/books/">
 </MAP>
</FOOTER>

4.7.12 area芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所、ただし先祖map芁玠たたは先祖template芁玠が存圚する堎合のみを陀く。
コンテンツモデル
空。
コンテンツ属性
グロヌバル属性
alt - 画像が利甚䞍可の際䜿甚する眮換テキスト
coords - むメヌゞマップ内に䜜成する図圢の座暙
download - リ゜ヌスをナビゲヌトする代わりにダりンロヌドし、その堎合リ゜ヌスのファむル名にするかどうか
href — ハむパヌリンクのアドレス
hreflang — リンクされたリ゜ヌスの蚀語
rel — ハむパヌリンクず宛先のリ゜ヌスを含む文曞の関係
shape - むメヌゞマップ内に䜜成する図圢の皮類
target -ハむパヌリンクナビゲヌションに察するブラりゞングコンテキスト
type — 参照されるリ゜ヌスタむプのヒント
text/htmlにおけるタグ省略
終了タグなし
蚱可されるARIAロヌル属性倀
link デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLAreaElement : HTMLElement {
           attribute DOMString alt;
           attribute DOMString coords;
           attribute DOMString shape;
           attribute DOMString target;
           attribute DOMString download;

           attribute DOMString rel;
  readonly attribute DOMTokenList relList;
           attribute DOMString hreflang;
           attribute DOMString type;
};
HTMLAreaElement implements URLUtils;

area芁玠は、テキストずむメヌゞマップで領域に察応をも぀ハむパヌリンク、たたはむメヌゞマップ䞊の䞍感領域のいずれかを衚す。

芪ノヌドずずもにarea芁玠は、map芁玠の祖先たたはtemplate芁玠の祖先を持たなければならない。

area芁玠がhref属性を持぀堎合、area芁玠はハむパヌリンクを衚す。この堎合、alt属性が存圚しなければならない。この属性は、ハむパヌリンクのテキストを指定する。属性倀は、むメヌゞマップの他のハむパヌリンクに指定されるテキストを䌎い、か぀画像の代替テキストを䌎うが、画像なしで提瀺された堎合、テキストでなければならず、テキストなしだが画像に適甚される圢状を䌎うような堎合、ハむパヌリンクずしお同じ遞択の皮類をナヌザヌに提䟛しなければならない。同じリ゜ヌスを指すむメヌゞマップず非空癜のalt属性を持぀別のarea芁玠が存圚する堎合、alt属性は空癜のたたであっおもよい。

area芁玠がhref属性を持たない堎合、その芁玠によっお衚される領域を遞択できず、alt属性を省略しなければならない。

どちらの堎合も、shapeずcoords属性は領域を指定する。

shape属性は、列挙属性である。以䞋の衚は、この属性に察しお定矩されたキヌワヌドを列挙する。キヌワヌドずずもにその行の最初のセルに䞎えられた状態は、これらキヌワヌドが察応する状態を䞎える。Some of the keywords are non-conforming, as noted in the last column.

状態 キヌワヌド 泚
Circle state circle
circ Non-conforming
Default state default
Polygon state poly
polygon Non-conforming
Rectangle state rect
rectangle Non-conforming

属性は省略しおもよい。欠損倀のデフォルトは、rectangle状態である。

coords属性が指定される堎合、敎数の劥圓なリストを含たなければならない。この属性は、shape属性によっお蚘述された図圢の座暙を䞎える。The processing for this attribute is described as part of the image map processing model.

circle stateにおいお、area芁玠は、最埌の敎数は非負でなければならない、3぀の敎数ずずもに、存圚するcoords属性を持たなければならない。最初の敎数は画像の巊端から円の䞭心たでのCSSピクセル単䜍距離でなければならず、2番目の敎数は画像の䞊端から円の䞭心たでのCSSピクセル単䜍距離でなければならず、3番目の敎数はCSSピクセル単䜍距離で円の半埄でなければならない。

default state状態においお、area芁玠はcoords属性を持っおはならない。領域は党䜓の画像である。

polygon stateにおいお、area芁玠は少なくずも6぀の敎数をも぀coords属性を持たなければならず、その敎数は偶数個でなければならない。敎数の各ペアは、CSSピクセルでそれぞれ画像の巊からおよび䞊からの距離ずしお指定された座暙を衚さなければならず、順に、すべおの座暙はポリゎンの点を衚さなければならない。

rectangle stateにおいお、area芁玠は正確に4぀の敎数をも぀coords属性を持たなければならない。1番目の敎数は3番目の敎数未満でなければならず、2番目の敎数は4番目の敎数未満でなければならない。4点は、それぞれすべおCSSピクセルで、矩圢の巊偎から画像の巊蟺たでの距離、䞊偎から䞊蟺たでの距離、巊偎から巊蟺たでの距離、䞋偎から䞊蟺たでの距離を衚さなければならない。

When user agents allow users to follow hyperlinks or download hyperlinks created using the area element, as described in the next section, the href, target, download, and attributes decide how the link is followed. The rel, hreflang, and type attributes may be used to indicate to the user the likely nature of the target resource before the user follows the link.

href属性が存圚しない堎合、target、hreflang、およびtype属性は省略しなければならない。

The activation behavior of area elements is to run the following steps:

  1. If the area element's Document is not fully active, then abort these steps.

  2. If the area element has a download attribute and the algorithm is not allowed to show a popup, or the element's target attribute is present and applying the rules for choosing a browsing context given a browsing context name, using the value of the target attribute as the browsing context name, would result in there not being a chosen browsing context, then run these substeps:

    1. If there is an entry settings object, throw an InvalidAccessError exception.

    2. Abort these steps without following the hyperlink.

  3. Otherwise, the user agent must follow the hyperlink or download the hyperlink created by the area element, if any, and as determined by the download attribute and any expressed user preference.

The IDL attributes alt, coords, target, download, rel, hreflang, and type, each must reflect the respective content attributes of the same name.

The IDL attribute shape must reflect the shape content attribute.

The IDL attribute relList must reflect the rel content attribute.


The area element also supports the URLUtils interface. [URL]

When the element is created, and whenever the element's href content attribute is set, changed, or removed, the user agent must invoke the element's URLUtils interface's set the input algorithm with the value of the href content attribute, if any, or the empty string otherwise, as the given value.

The element's URLUtils interface's get the base algorithm must simply return the element's base URL.

The element's URLUtils interface's query encoding is the document's character encoding.

When the element's URLUtils interface invokes its update steps with a string value, the user agent must set the element's href content attribute to the string value.

4.7.13 むメヌゞマップ

4.7.13.1 Authoring

むメヌゞマップは、ハむパヌリンクに関連付けられるような画像で幟䜕孊的な領域を可胜にする。

img芁玠や画像を衚すobject芁玠の圢匏においお、画像は、imgやobject芁玠䞊でusemap属性を指定するこずによりmap芁玠の圢匏でむメヌゞマップに関連付けおもよい。usemap属性が指定される堎合、map芁玠に劥圓なハッシュ名の参照でなければならない。

次のような画像を考えおみよう

A line with four shapes in it, equally spaced: a red hollow box, a green circle, a blue triangle, and a yellow four-pointed star.

色付きの領域のみをクリック可胜にしたい堎合、次のようにするだろう

<p>
 Please select a shape:
 <img src="shapes.png" usemap="#shapes"
      alt="Four shapes are available: a red hollow box, a green circle, a blue triangle, and a yellow four-pointed star.">
 <map name="shapes">
  <area shape=rect coords="50,50,100,100"> <!-- the hole in the red box -->
  <area shape=rect coords="25,25,125,125" href="red.html" alt="Red box.">
  <area shape=circle coords="200,75,50" href="green.html" alt="Green circle.">
  <area shape=poly coords="325,25,262,125,388,125" href="blue.html" alt="Blue triangle.">
  <area shape=poly coords="450,25,435,60,400,75,435,90,450,125,465,90,500,75,465,60"
        href="yellow.html" alt="Yellow star.">
 </map>
</p>
4.7.13.2 Processing model

If an img element or an object element representing an image has a usemap attribute specified, user agents must process it as follows:

  1. First, rules for parsing a hash-name reference to a map element must be followed. This will return either an element (the map) or null.

  2. If that returned null, then abort these steps. The image is not associated with an image map after all.

  3. Otherwise, the user agent must collect all the area elements that are descendants of the map. Let those be the areas.

Having obtained the list of area elements that form the image map (the areas), interactive user agents must process the list in one of two ways.

If the user agent intends to show the text that the img element represents, then it must use the following steps.

In user agents that do not support images, or that have images disabled, object elements cannot represent images, and thus this section never applies (the fallback content is shown instead). The following steps therefore only apply to img elements.

  1. Remove all the area elements in areas that have no href attribute.

  2. Remove all the area elements in areas that have no alt attribute, or whose alt attribute's value is the empty string, if there is another area element in areas with the same value in the href attribute and with a non-empty alt attribute.

  3. Each remaining area element in areas represents a hyperlink. Those hyperlinks should all be made available to the user in a manner associated with the text of the img.

    In this context, user agents may represent area and img elements with no specified alt attributes, or whose alt attributes are the empty string or some other non-visible text, in a user-agent-defined fashion intended to indicate the lack of suitable author-provided text.

If the user agent intends to show the image and allow interaction with the image to select hyperlinks, then the image must be associated with a set of layered shapes, taken from the area elements in areas, in reverse tree order (so the last specified area element in the map is the bottom-most shape, and the first element in the map, in tree order, is the top-most shape).

Each area element in areas must be processed as follows to obtain a shape to layer onto the image:

  1. Find the state that the element's shape attribute represents.

  2. Use the rules for parsing a list of integers to parse the element's coords attribute, if it is present, and let the result be the coords list. If the attribute is absent, let the coords list be the empty list.

  3. If the number of items in the coords list is less than the minimum number given for the area element's current state, as per the following table, then the shape is empty; abort these steps.

    状態 Minimum number of items
    Circle state 3
    Default state 0
    Polygon state 6
    Rectangle state 4
  4. Check for excess items in the coords list as per the entry in the following list corresponding to the shape attribute's state:

    Circle state
    Drop any items in the list beyond the third.
    Default state
    Drop all items in the list.
    Polygon state
    Drop the last item if there's an odd number of items.
    Rectangle state
    Drop any items in the list beyond the fourth.
  5. If the shape attribute represents the rectangle state, and the first number in the list is numerically less than the third number in the list, then swap those two numbers around.

  6. If the shape attribute represents the rectangle state, and the second number in the list is numerically less than the fourth number in the list, then swap those two numbers around.

  7. If the shape attribute represents the circle state, and the third number in the list is less than or equal to zero, then the shape is empty; abort these steps.

  8. Now, the shape represented by the element is the one described for the entry in the list below corresponding to the state of the shape attribute:

    Circle state

    Let x be the first number in coords, y be the second number, and r be the third number.

    The shape is a circle whose center is x CSS pixels from the left edge of the image and y CSS pixels from the top edge of the image, and whose radius is r pixels.

    Default state

    The shape is a rectangle that exactly covers the entire image.

    Polygon state

    Let xi be the (2i)th entry in coords, and yi be the (2i+1)th entry in coords (the first entry in coords being the one with index 0).

    Let the coordinates be (xi, yi), interpreted in CSS pixels measured from the top left of the image, for all integer values of i from 0 to (N/2)-1, where N is the number of items in coords.

    The shape is a polygon whose vertices are given by the coordinates, and whose interior is established using the even-odd rule. [GRAPHICS]

    Rectangle state

    Let x1 be the first number in coords, y1 be the second number, x2 be the third number, and y2 be the fourth number.

    The shape is a rectangle whose top-left corner is given by the coordinate (x1, y1) and whose bottom right corner is given by the coordinate (x2, y2), those coordinates being interpreted as CSS pixels from the top left corner of the image.

    For historical reasons, the coordinates must be interpreted relative to the displayed image after any stretching caused by the CSS 'width' and 'height' properties (or, for non-CSS browsers, the image element's width and height attributes — CSS browsers map those attributes to the aforementioned CSS properties).

    Browser zoom features and transforms applied using CSS or SVG do not affect the coordinates.

Pointing device interaction with an image associated with a set of layered shapes per the above algorithm must result in the relevant user interaction events being first fired to the top-most shape covering the point that the pointing device indicated, if any, or to the image element itself, if there is no shape covering that point. User agents may also allow individual area elements representing hyperlinks to be selected and activated (e.g. using a keyboard).

Because a map element (and its area elements) can be associated with multiple img and object elements, it is possible for an area element to correspond to multiple focusable areas of the document.

Image maps are live; if the DOM is mutated, then the user agent must act as if it had rerun the algorithms for image maps.

4.7.14 MathML

MathML名前空間由来のmath芁玠は、この仕様におけるコンテンツモデルの意味に察しお゚ンベディッドコンテンツ、フレヌゞングコンテンツ、およびフロヌコンテンツのカテゎリに分類される。

User agents must handle text other than inter-element whitespace found in MathML elements whose content models do not allow straight text by pretending for the purposes of MathML content models, layout, and rendering that that text is actually wrapped in an mtext element in the MathML namespace. (Such text is not, however, conforming.)

User agents must act as if any MathML element whose contents does not match the element's content model was replaced, for the purposes of MathML layout and rendering, by an merror element in the MathML namespace containing some appropriate error message.

To enable authors to use MathML tools that only accept MathML in its XML form, interactive HTML user agents are encouraged to provide a way to export any MathML fragment as an XML namespace-well-formed XML fragment.

MathMLの芁玠のセマンティックは、MathML仕様やその他の適甚可胜な仕様で定矩される。[MATHML]

HTML文曞でのMathMLの䜿甚䟋は、次のずおり

<!DOCTYPE html>
<html>
 <head>
  <title>The quadratic formula</title>
 </head>
 <body>
  <h1>The quadratic formula</h1>
  <p>
   <math>
    <mi>x</mi>
    <mo>=</mo>
    <mfrac>
     <mrow>
      <mo form="prefix">−</mo> <mi>b</mi>
      <mo>±</mo>
      <msqrt>
       <msup> <mi>b</mi> <mn>2</mn> </msup>
       <mo>−</mo>
       <mn>4</mn> <mo>⁢</mo> <mi>a</mi> <mo>⁢</mo> <mi>c</mi>
      </msqrt>
     </mrow>
     <mrow>
      <mn>2</mn> <mo>⁢</mo> <mi>a</mi>
     </mrow>
    </mfrac>
   </math>
  </p>
 </body>
</html>

4.7.15 SVG

SVG名前空間由来のsvg芁玠は、この仕様におけるコンテンツモデルの意味に察しお゚ンベディッドコンテンツ、フレヌゞングコンテンツ、およびフロヌコンテンツのカテゎリに分類される。

To enable authors to use SVG tools that only accept SVG in its XML form, interactive HTML user agents are encouraged to provide a way to export any SVG fragment as an XML namespace-well-formed XML fragment.

SVGのforeignObject芁玠がHTML名前空間の芁玠を含む堎合、そのような芁玠は、すべおフロヌコンテンツでなければならない。[SVG]

HTML文曞内郚のSVG名前空間でtitle芁玠のコンテンツモデルはフレヌゞングコンテンツである。これはSVG仕様で指定された芁件をさらに制玄する。

SVGの芁玠のセマンティックは、SVG仕様やその他の適甚可胜な仕様で定矩される。[SVG]

SVG仕様は、SVG名前空間になく、SVGの断片であり、foreignObject芁玠に含たれないDOM内の芁玠の取り扱いに関する芁件を含む。この仕様は、HTML名前空間でないSVG断片での芁玠に察する任意の凊理を定矩しない。それらは、この仕様の芳点から適合でも䞍適合でもないず考えられる。

4.7.16 次元属性

Author requirements: The width and height attributes on img, iframe, embed, object, video, and, when their type attribute is in the Image Button state, input elements may be specified to give the dimensions of the visual content of the element (the width and height respectively, relative to the nominal direction of the output medium), in CSS pixels. The attributes, if specified, must have values that are valid non-negative integers.

リ゜ヌスはCSSピクセルの解像床ずは異なる解像床を持぀かもしれないので、䞎えられた指定次元は、リ゜ヌス自䜓で指定された次元ず異なるかもしれない。画面では、CSSのピクセルが96ppiの解像床を持぀が、䞀般にCSSピクセル解像床が読み取り距離に䟝存する。䞡方の属性が指定される堎合、次のいずれかの呜題が真でなければならない

target ratioは、リ゜ヌスの固有高さず固有幅の比率である。specified widthずspecified heightは、それぞれwidthずheight属性の倀である。

問題のリ゜ヌスが固有幅ず固有高さの䞡方を持たない堎合、2぀の属性は省略しなければならない。

2぀の属性がずもに0である堎合、芁玠がナヌザヌに意図されないたずえば、ペヌゞビュヌをカりントするサヌビスの䞀郚であるかもしれないこずを瀺す。

次元属性は、画像を䌞ばすために䜿甚するこずを意図しない。

User agent requirements: User agents are expected to use these attributes as hints for the rendering.

The width and height IDL attributes on the iframe, embed, object, and video elements must reflect the respective content attributes of the same name.

For iframe, embed, and object the IDL attributes are DOMString; for video the IDL attributes are unsigned long.

The corresponding IDL attributes for img and input elements are defined in those respective elements' sections, as they are slightly more specific to those elements' other behaviors.