차례
      1. 4.8.6 The video element
      2. 4.8.7 The audio element
      3. 4.8.8 The source element
      4. 4.8.9 The track element
      5. 4.8.10 Media elements
        1. 4.8.10.1 에러 코드
        2. 4.8.10.2 미디어 자원의 위치
        3. 4.8.10.3 마임 타입
        4. 4.8.10.4 네트워크 상태
        5. 4.8.10.5 미디어 자원 로딩
        6. 4.8.10.6 미디어 자원으로의 오프셋
        7. 4.8.10.7 "준비됨" 상태
        8. 4.8.10.8 미디어 자원 재생
        9. 4.8.10.9 탐색
        10. 4.8.10.10 시간이 설정된 텍스트 트랙
          1. 4.8.10.10.1 텍스트 트랙 모델
          2. 4.8.10.10.2 Sourcing in-band text tracks
          3. 4.8.10.10.3 Sourcing out-of-band text tracks
          4. 4.8.10.10.4 텍스트 트랙 API
          5. 4.8.10.10.5 이벤트 정의
        11. 4.8.10.11 사용자 인터페이스
        12. 4.8.10.12 시간 범위
        13. 4.8.10.13 이벤트 요약
        14. 4.8.10.14 보안과 프라이버시에 관한 고려
        15. 4.8.10.15 미디어 요소 구현의 모범 사례(웹 저자)
        16. 4.8.10.16 미디어 요소 구현의 모범 사례(구현자)

4.8.6 The video element

ISSUE-9 (video-accessibility) blocks progress to Last Call

요소가 속하는 범주Categories
플로우 컨텐츠Flow content
구문 컨텐츠Phrasing content
포함된 컨텐츠Embedded content

요소에 controls 속성이 있으면: 대화형 컨텐츠

If the element has a controls attribute: Interactive content.

이 요소가 사용될 수 있는 문맥:Contexts in which this element can be used

포함된 컨텐츠가 올 수 있는 곳

Where embedded content is expected.

이 요소가 포함할 수 있는 것:Content model

src 속성이 있는 경우: 0개 이상의 track 요소 → 투명한 요소. 하지만 미디어 요소를 자손으로 가질 수는 없습니다.

If the element has a src attribute: zero or more track elements, then transparent, but with no media element descendants.

src 속성이 없는 경우: 0개 이상의 source 요소 → 0개 이상의 track 요소 → 투명한 요소. 하지만 미디어 요소를 자손으로 가질 수는 없습니다.

If the element does not have a src attribute: one or more source elements, then zero or more track elements, then transparent, but with no media element descendants.

요소에 사용할 수 있는 속성:Content attributes
전역 속성Global attributes
src
poster
preload
autoplay
loop
audio
controls
width
height
DOM interface:
interface HTMLVideoElement : HTMLMediaElement {
           attribute unsigned long width;
           attribute unsigned long height;
  readonly attribute unsigned long videoWidth;
  readonly attribute unsigned long videoHeight;
           attribute DOMString poster;
  [PutForwards=value attribute DOMSettableTokenList audio; 
};

video 요소는 비디오, 혹은 영화를 재생하기 위해 사용됩니다.

A video element is used for playing videos or movies.

video 요소를 지원하지 않는 오래된 웹 브라우저에서 구형 비디오 플러그인을 시도하거나, 사용자가 비디오 컨텐츠에 접근할 수 있는 방법을 제시하는 텍스트를 보여줄 수 있도록 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.

video 요소 내부에 컨텐츠를 제공하는 것이 접근성을 고려한 것은 아닙니다. 시각이나 청각, 기타 장애를 가진 사람이 비디오 컨텐츠를 이용할 수 있게 하려면 대체수단이 될 수 있는 다른 미디어 스트림 그리고/또는 접근성 도구(자막 등)을 미디어 스트림에 병합하는 방법을 고려해야 할 것입니다.

In particular, this content is not intended to address accessibility concerns. To make video content accessible to the blind, deaf, and those with other physical or cognitive disabilities, authors are expected to provide alternative media streams and/or to embed accessibility aids (such as caption or subtitle tracks, audio description tracks, or sign-language overlays) into their media streams.

video 요소는 표면상 비디오 데이터이면서 오디오 데이터와 연결되어 있을 가능성이 있는 미디어 데이터를 나타내는 미디어 요소입니다.

The video element is a media element whose media data is ostensibly video data, possibly with associated audio data.

src, preload, autoplay, loop, controls 속성은 모든 미디어 요소에 공통된 속성입니다. audio 속성은 오디오 채널을 제어합니다.

The src, preload, autoplay, loop, and controls attributes are the attributes common to all media elements. The audio attribute controls the audio channel.

poster 속성은 사용자 에이전트가 비디오 데이터를 사용할 수 없을 때 보여줄 이미지 파일의 주소를 지정합니다. 속성의 값은 유효한, 앞뒤로 공백을 허용하고 비어 있지 않은 URL 이어야 합니다.

The poster attribute gives the address of an image file that the user agent can show while no video data is available. The attribute, if present, must contain a valid non-empty URL potentially surrounded by spaces.

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:

  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, 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 속성으로 나타내는 이미지를 포스터 프레임이라 합니다. 사용자가 포스터 프레임을 보고 비디오가 어떤 것인지 짐작할 수 있도록 대표적인 프레임(일반적으로, 공백이 아닌 최초 몇 프레임 중 하나)을 사용해야 합니다.

The image given by the poster attribute, the poster frame, is intended to be a representative frame of the video (typically one of the first non-blank frames) that gives the user an idea of what the video is like.


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), the video element represents either the poster frame, or nothing.

When a video element is paused and the current playback position is the first frame of video, the element represents either the frame of video corresponding to the current playback position or the poster frame, at the discretion of the user agent.

Notwithstanding the above, the poster frame should be preferred over nothing, but the poster frame should not be shown again after a frame of video has been shown.

When a video element is paused at any other position, the element represents the frame of video corresponding to the current playback position, or, if that is not yet available (e.g. because the video is seeking or buffering), the last frame of the video to have been rendered.

When a video element is potentially playing, it 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. Similarly, any audio associated with the video must, if played, be played synchronized with the current playback position, at the specified volume with the specified mute state.

When a video element is neither potentially playing nor paused (e.g. when seeking or stalled), the element represents the last frame of the video to have been 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 or showing by default modes.

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.


video . videoWidth
video . videoHeight

이 속성은 비디오의 고유한 크기를 반환하며, 그러한 것을 알 수 없다면 0 을 반환합니다.

These attributes return the intrinsic dimensions of the video, or zero if the dimensions are not known.

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.

video 요소에 크기 속성을 쓸 수 있습니다.

The video element supports dimension attributes.

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.

The intrinsic width of a video element's playback area is the intrinsic width of the video resource, if that is available; otherwise it is the intrinsic width of the poster frame, if that is available; otherwise it is 300 CSS pixels.

The intrinsic height of a video element's playback area is the intrinsic height of the video resource, if that is available; otherwise it is the intrinsic height of the poster frame, if that is available; otherwise it is 150 CSS pixels.


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.

The audio IDL attribute must reflect the audio content attribute.

아래의 예제는 비디오가 정확히 재생되지 못한 것을 어떻게 감지하는지 보여줍니다.

This example shows how to detect when a video has failed to play correctly:

<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.8.7 The audio element

요소가 속하는 범주Categories
플로우 컨텐츠Flow content
구문 컨텐츠Phrasing content
포함된 컨텐츠Embedded content

요소가 controls 속성을 가졌다면: 대화형 컨텐츠

If the element has a controls attribute: Interactive content.

이 요소가 사용될 수 있는 문맥:Contexts in which this element can be used

포함된 컨텐츠가 올 수 있는 곳

Where embedded content is expected.

이 요소가 포함할 수 있는 것:Content model

src 속성이 있는 경우: 0개 이상의 track 요소 → 투명한 요소. 하지만 미디어 요소를 자손으로 가질 수는 없습니다.

If the element has a src attribute: zero or more track elements, then transparent, but with no media element descendants.

src 속성이 없는 경우: 0개 이상의 source 요소 → 0개 이상의 track 요소 → 투명한 요소. 하지만 미디어 요소를 자손으로 가질 수는 없습니다.

If the element does not have a src attribute: one or more source elements, then zero or more track elements, then transparent, but with no media element descendants.

요소에 사용할 수 있는 속성:Content attributes
전역 속성Global attributes
src
preload
autoplay
loop
controls
DOM interface:
[NamedConstructor=Audio(),
 NamedConstructor=Audio(in DOMString src)]
interface HTMLAudioElement : HTMLMediaElement {};

audio 요소는 소리 또는 오디오 스트림을 나타냅니다.

An audio element represents a sound or audio stream.

audio 요소 내부에 컨텐츠를 제공할 수 있습니다. 이렇게 하면 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.

audio 요소 내부에 제공한 컨텐츠는 접근성과는 관계가 없습니다. 청각, 기타 장애를 가진 사람들이 오디오 컨텐츠를 사용할 수 있게 하려면 대체적인 미디어 스트림, 그리고/또는 자막 같은 접근성 도구들을 미디어 스트림에 병합하는 방법을 고려해야 할 것입니다.

In particular, this content is not intended to address accessibility concerns. To make audio content accessible to the deaf or to those with other physical or cognitive disabilities, authors are expected to provide alternative media streams and/or to embed accessibility aids (such as transcriptions) into their media streams.

audio 요소는 그 미디어 데이터가 표면상 오디오 데이터인 미디어 요소입니다.

The audio element is a media element whose media data is ostensibly audio data.

src, preload, autoplay, loop, controls 속성은 모든 미디어 요소에 공통입니다.

The src, preload, autoplay, loop, and controls attributes are the attributes common to all media elements.

When an audio element is potentially playing, it must have its audio data played synchronized with the current playback position, at the specified volume with the specified mute state.

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

audio = new Audio( [ url ] )

새로운 audio 요소를 반환합니다. 새 요소의 src 속성은 매개변수로 전달된 값으로 설정됩니다.

Returns a new audio element, with the src attribute set to the value passed in the argument, if applicable.

Two constructors are provided for creating HTMLAudioElement objects (in addition to the factory methods from DOM Core such as createElement()): Audio() and Audio(src). When invoked as constructors, these 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.8.8 The source element

요소가 속하는 범주Categories
없음None
이 요소가 사용될 수 있는 문맥:Contexts in which this element can be used

미디어 요소의 자식 요소. 어떤 플로우 컨텐츠track 요소보다 앞에 있어야 합니다.

As a child of a media element, before any flow content or track elements.

이 요소가 포함할 수 있는 것:Content model
이 요소는 비어 있어야 합니다.Empty
요소에 사용할 수 있는 속성:Content attributes
전역 속성Global attributes
src
type
media
DOM interface:
interface HTMLSourceElement : HTMLElement {
           attribute DOMString src;
           attribute DOMString type;
           attribute DOMString media;
};

source 요소는 미디어 요소에서 사용할 수 있는 대체 미디어 자원을 제공합니다. source 요소는 그 자신으로서는 아무것도 나타내지 않습니다.

The source element allows authors to specify multiple alternative media resources for media elements. It does not represent anything on its own.

src 속성으로 그러한 미디어 자원의 주소를 설정합니다. 값은 유효한, 앞뒤로 공백을 허용하고 비어 있지 않은 URL이어야 하며, 이 속성은 반드시 존재하여야 합니다.

The src attribute gives the address of the media resource. The value must be a valid non-empty URL potentially surrounded by spaces. This attribute must be present.

요소가 이미 video 또는 video 요소에 삽입된 상태에서 source 요소와 그 속성을 동적으로 변경하는 것은 아무런 효과가 없습니다. 현재 재생되고 있는 것을 변경하려면 src 속성을 직접 변경하거나 source 요소를 조작한 뒤에 load() 메서드를 호출해야 합니다.

Dynamically modifying a source element and its attribute when the element is already inserted in a video or audio element will have no effect. To change what is playing, either just use the src attribute on the media element directly, or call the load() method on the media element after manipulating the source elements.

사용자 에이전트가 미디어 자원을 가져오려는 시도를 하기 전에 자신이 재생할 수 있는 자원인지 판단할 수 있도록 type 속성으로 미디어 자원의 타입을 제공할 수 있습니다. type 속성의 값은 유효한 MIME 타입이어야 합니다. 정확히 어떠한 자원이 인코드되었는지 명시하기 위해 codecs 매개변수를 써야 할 수도 있습니다. [RFC4281]

The type attribute gives the type of the media resource, to help the user agent determine if it can play this media resource before fetching it. If specified, its value must be a valid MIME type. The codecs parameter, which certain MIME types define, might be necessary to specify exactly how the resource is encoded. [RFC4281]

다음의 목록은 codecs= 마임 매개변수를 type 속성에서 사용하는 몇가지 예제를 보여줍니다. 역주

The following list shows some examples of how to use the codecs= MIME parameter in the type attribute.

H.264 Constrained baseline profile video (main and extended video compatible) level 3 and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
H.264 Extended profile video (baseline-compatible) level 3 and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="avc1.58A01E, mp4a.40.2"'>
H.264 Main profile video level 3 and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'>
H.264 'High' profile video (incompatible with main, baseline, or extended profiles) level 3 and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="avc1.64001E, mp4a.40.2"'>
MPEG-4 Visual Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="mp4v.20.8, mp4a.40.2"'>
MPEG-4 Advanced Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="mp4v.20.240, mp4a.40.2"'>
MPEG-4 Visual Simple Profile Level 0 video and AMR audio in 3GPP container
<source src='video.3gp' type='video/3gpp; codecs="mp4v.20.8, samr"'>
Theora video and Vorbis audio in Ogg container
<source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'>
Theora video and Speex audio in Ogg container
<source src='video.ogv' type='video/ogg; codecs="theora, speex"'>
Vorbis audio alone in Ogg container
<source src='audio.ogg' type='audio/ogg; codecs=vorbis'>
Speex audio alone in Ogg container
<source src='audio.spx' type='audio/ogg; codecs=speex'>
FLAC audio alone in Ogg container
<source src='audio.oga' type='audio/ogg; codecs=flac'>
Dirac video and Vorbis audio in Ogg container
<source src='video.ogv' type='video/ogg; codecs="dirac, vorbis"'>
Theora video and Vorbis audio in Matroska container
<source src='video.mkv' type='video/x-matroska; codecs="theora, vorbis"'>

media 속성을 이용해서 미디어 자원에서 의도한 미디어 타입을 지정할 수 있습니다. 이렇게 하면 사용자 에이전트가 자원을 가져오기 전에 그러한 미디어 자원이 사용자에게 유용한지 판단할 수 있습니다. 값은 유효한 미디어 쿼리여야 합니다.

The media attribute gives the intended media type of the media resource, to help the user agent determine if this media resource is useful to the user before fetching it. Its value must be a valid media query.

media 속성을 생략했다면 기본값은 "all"입니다. 모든 매체가 그 미디어 자원에 적합함을 의미합니다.

The default, if the media attribute is omitted, is "all", meaning that by default the media resource is suitable for all media.

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 이벤트를 검사해서 폴백을 발생시킬 수 있습니다.

If the author isn't sure if the user agents will all be able to render the media resources provided, the author can listen to the error event on the last source element and trigger fallback behavior:

<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.8.9 The track element

ISSUE-9 (video-accessibility) blocks progress to Last Call

요소가 속하는 범주Categories
없음None
이 요소가 사용될 수 있는 문맥:Contexts in which this element can be used

미디어 요소의 자식 요소. 어떤 플로우 컨텐츠보다도 앞에 있어야 합니다.

As a child of a media element, before any flow content.

이 요소가 포함할 수 있는 것:Content model
이 요소는 비어 있어야 합니다.Empty
요소에 사용할 수 있는 속성:Content attributes
전역 속성Global attributes
kind
src
srclang
label
default
DOM interface:
interface HTMLTrackElement : HTMLElement {
           attribute DOMString kind;
           attribute DOMString src;
           attribute DOMString srclang;
           attribute DOMString label;
           attribute boolean default;

  readonly attribute TextTrack track;
};

미디어 요소track 요소를 써서 명시적인 외부 텍스트 트랙을 지정할 수 있습니다. 이 요소는 자체로서는 아무것도 나타내지 않습니다.

The track element allows authors to specify explicit external timed text tracks for media elements. It does not represent anything on its own.

kind 속성은 나열 속성입니다. 다음의 표는 이 속성에서 사용할 수 있는 키워드 목록입니다. 각 행의 첫번째 열에 있는 키워드가 두번째 열의 상태에 대응합니다.

The kind attribute is an enumerated attribute. The following table lists the keywords defined for this attribute. The keyword given in the first cell of each row maps to the state given in the second cell.

Keyword State Brief description
subtitles Subtitles

사용자가 미디어 자원의 언어를 이해하지 못하는 등의 이유로 소리가 들리지만 이해할 수 없는 경우에 적합한 대화의 자막 또는 번역입니다. 비디오에 오버레이됩니다.

Transcription or translation of the dialogue, suitable for when the sound is available but not understood (e.g. because the user does not understand the language of the media resource's soundtrack). Displayed over the video.

captions Captions

음소거를 했거나 사용자가 청각 장애를 갖고 있는 등의 이유로 소리를 들을 수 없는 경우에 적합한 대화, 음향효과, 관련있는 음악적 단서, 기타 관련있는 오디오 정보의 자막 또는 번역입니다. 비디오에 오버레이되며, 소리를 듣기 힘든 이에게 적합하다는 표식이 붙습니다.

Transcription or translation of the dialogue, sound effects, relevant musical cues, and other relevant audio information, suitable for when the soundtrack is unavailable (e.g. because it is muted or because the user is deaf). Displayed over the video; labeled as appropriate for the hard-of-hearing.

descriptions Descriptions

미디어 자원의 비디오 부분에 대한 텍스트 형태의 설명입니다. 운전중에 화면을 보지 않으면서 프로그램을 조작한다거나, 사용자에게 시각장애가 있거나 하는 이유로 비디오 부분을 사용할 수 없을 때 오디오를 통합하기 위해 사용합니다. 분리된 오디오 트랙으로 재생됩니다.

Textual descriptions of the video component of the media resource, intended for audio synthesis when the visual component is unavailable (e.g. because the user is interacting with the application without a screen while driving, or because the user is blind). Synthesized as separate audio track.

chapters Chapters

챕터 제목입니다. 미디어 자원의 내비게이션으로 사용할 수 있습니다. 사용자 에이전트의 인터페이스에는 대화형 목록으로 표시됩니다.

Chapter titles, intended to be used for navigating the media resource. Displayed as an interactive list in the user agent's interface.

metadata Metadata

스크립트에서 사용할 트랙입니다. 사용자 에이전트에서는 표현되지 않습니다.

Tracks intended for use from script. Not displayed by the user agent.

속성을 생략했을 때의 기본값subtitles 상태입니다.

The attribute may be omitted. The missing value default is the subtitles state.

src 속성으로 텍스트 트랙 데이터의 주소를 제공합니다. 값은 반드시 유효한, 앞뒤로 공백을 허용하고 비어 있지 않은 URL이어야 하며, 이 속성을 생략할수는 없습니다.

The src attribute gives the address of the text track data. The value must be a valid non-empty URL potentially surrounded by spaces. This attribute must be present.

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.

srclang 속성으로 텍스트 트랙 데이터의 언어를 지정합니다. 값은 반드시 유효한 BCP 47 언어 태그여야 합니다. 요소의 kind 속성이 subtitles 상태일때는 이 속성을 생략할 수 없습니다. [BCP47]

The srclang attribute gives the language of the text track data. The value must be a valid BCP 47 language tag. This attribute must be present if the element's kind attribute is in the subtitles state. [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 속성으로 사용자가 읽을 수 있는 트랙 제목을 제공합니다. 사용자 에이전트에서는 이 값을 사용해서 subtitlecaption, audio description 트랙을 인터페이스에 표현합니다.

The label attribute gives a user-readable title for the track. This title is used by user agents when listing subtitle, caption, and audio description tracks in their user interface.

label 속성을 사용했다면 그 값은 빈 문자열이 될 수 없습니다. 또한 동일한 미디어 요소에서 kind 속성, srclang 속성, label 속성의 값이 모두 같은 track 요소를 사용할 수는 없습니다. 이러한 비교는 속성이 양쪽 모두 생략되었을 경우에는 같은 값을 갖는 것으로 간주합니다.

The value of the label attribute, if the attribute is present, must not be the empty string. Furthermore, there must not be two track element children of the same media element whose kind attributes are in the same state, whose srclang attributes are both missing or have values that represent the same language, and whose label attributes are again both missing or both have the same value.

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 a user-agent defined string (e.g. the string "untitled" in the user's locale, or a value automatically generated from the other attributes).

default 속성은 사용자의 선호preference에 더 적합한 것이 없다면 이 트랙을 사용할 것이라는 뜻을 나타냅니다. 같은 부모 요소에서 default 속성을 가진 track 요소는 단 하나만 사용할 수 있습니다.

The default attribute, if specified, indicates that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate. There must not be more than one track element with the same parent node with the default attribute specified.

track . track

track 요소의 텍스트 트랙에 대응하는 TextTrack 객체를 반환합니다.

Returns the TextTrack object corresponding to the text track of the track element.

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.

이 비디오에는 여러 언어로 된 자막이 있습니다.

This video has subtitles in several languages:

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

4.8.10 미디어 요소

미디어 요소(이 명세에서 audiovideo)는 다음의 인터페이스를 구현합니다.

Media elements (audio and video, in this specification) implement the following interface:

interface HTMLMediaElement : HTMLElement {

  // error state
  readonly attribute MediaError error;

  // network state
           attribute DOMString src;
  readonly attribute DOMString currentSrc;
  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();
  DOMString canPlayType(in 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 double initialTime;
  readonly attribute double duration;
  readonly attribute Date startOffsetTime;
  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();

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

  // text tracks
  readonly attribute TextTrack[] tracks;
  MutableTextTrack addTrack(in DOMString kind, in optional DOMString label, in optional DOMString language);

};

미디어 요소 속성src, preload, autoplay, loop, controls 속성들은 미디어 요소에 공통으로 사용됩니다. 이러한 것들을 이 섹션에서 설명합니다.

The media element attributes, src, preload, autoplay, loop, and controls, apply to all media elements. They are defined in this section.

미디어 요소는 오디오 또는 비디오+오디오 데이터를 표현합니다. 이 섹션은 오디오와 비디오 양쪽에 동일하게 적용되므로 이 섹션에서는 이러한 것을 미디어 데이터 라고 부릅니다. 미디어 자원이라는 단어는 미디어 데이터의 완전한 형태, 즉 완전한 비디오 파일 또는 완전한 오디오 파일을 가리킵니다.

Media elements are used to present audio data, or video and audio data, to the user. This is referred to as media data in this section, since this section applies equally to media elements for audio or for video. The term media resource is used to refer to the complete set of media data, e.g. the complete video file, or complete audio file.

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

4.8.10.1 에러 코드
media . error

요소의 현재 에러 상태를 나타내는 MediaError 객체를 반환합니다

Returns a MediaError object representing the current error state of the element.

에러가 없다면 null을 반환합니다.

Returns null if there is no error.

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

현재 에러의 코드를 반환합니다. 자세한 것은 다음 목록을 보십시오.

Returns the current error's error code, from the list below.

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

MEDIA_ERR_ABORTED (numeric value 1)

미디어 자원을 가져오는 중에 사용자가 취소한 경우

The fetching process for the media resource was aborted by the user agent at the user's request.

MEDIA_ERR_NETWORK (numeric value 2)

미디어 자원을 사용할 수 있게 된 상태에서 발생한 네트워크 에러

A network error of some description caused the user agent to stop fetching the media resource, after the resource was established to be usable.

MEDIA_ERR_DECODE (numeric value 3)

미디어 자원을 디코드하는 과정에서 발생한 에러

An error of some description occurred while decoding the media resource, after the resource was established to be usable.

MEDIA_ERR_SRC_NOT_SUPPORTED (numeric value 4)

src 속성으로 지정된 미디어 자원이 적합하지 않은 경우

The media resource indicated by the src attribute was not suitable.

4.8.10.2 미디어 자원의 위치

내용 속성 src로 보여주고자 하는 미디어 자원의 주소를 제공합니다. 속성의 값은 유효한, 앞뒤로 공백을 허용하고 비어 있지 않은 URL이어야 합니다.

The src content attribute on media elements gives the address of the media resource (video, audio) to show. The attribute, if present, must contain a valid non-empty URL potentially surrounded by spaces.

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.

media . currentSrc

현재의 미디어 자원의 위치를 반환합니다.

Returns the address of the current media resource.

미디어 자원이 없을 경우에는 빈 문자열을 반환합니다.

Returns the empty string when there is no media resource.

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

미디어 자원을 명시하는데는 두가지 방법이 있습니다. 하나는 src 속성이고, 하나는 source 요소입니다. 속성이 요소보다 우선합니다.

There are two ways to specify a media resource, the src attribute, or source elements. The attribute overrides the elements.

4.8.10.3 마임 타입

미디어 자원마임 타입을 통해 설명됩니다. 선택적으로 codecs 매개변수를 덧붙일 수 있습니다.

A media resource can be described in terms of its type, specifically a MIME type, in some cases with a codecs parameter. (Whether the codecs parameter is allowed or not depends on the MIME type.) [RFC4281]

type은 보통 불충분한 설명입니다. 예를 들어, "video/mpeg" 라는 단어는 컨테이너 타입이 어떤 것인지는 전혀 나타내지 못합니다. "video/mp4; codecs="avc1.42E01E, mp4a.40.2"" 같은 단어도 실제 비트레이트를 나타내지는 못합니다(최대 비트레이트만 나타납니다) 따라서 사용자 에이전트가 타입을 통해 알 수 있는 것은 그것을 플레이 할 수 있을수도 있다, 또는 전혀 플레이 할 수 없다는 것 정도입니다.

Types are usually somewhat incomplete descriptions; for example "video/mpeg" doesn't say anything except what the container type is, and even a type like "video/mp4; codecs="avc1.42E01E, mp4a.40.2"" doesn't include information like the actual bitrate (only the maximum bitrate). Thus, given a type, a user agent can often only know whether it might be able to play media of that type (with varying levels of confidence), or whether it definitely cannot play media of that type.

렌더링 할 수 없음을 사용자 에이전트가 알고 있는 타입은 사용자 에이전트가 확실히 해당 자원을 지원하지 않음을 설명합니다. 컨테이너 타입을 인식하지 못하거나 나열된 코덱을 지원하지 않을 수도 있습니다.

A type that the user agent knows it cannot render is one that describes a resource that the user agent definitely does not support, for example because it doesn't recognize the container type, or it doesn't support the listed codecs.

매개변수 없이 "application/octet-stream" 이라는 마임 타입만 쓰면 렌더링 할 수 없음을 사용자 에이전트가 알고 있는 타입이 될 수 없습니다. 미디어 자원일 수 있는 자원이 이러한 타입이라면 사용자 에이전트는 이 자원을 명시적인 content-type 메타데이터가 부족한 타입과 똑같이 다루어야 합니다.

The MIME type "application/octet-stream" with no parameters is never a type that the user agent knows it cannot render. User agents must treat that type as equivalent to the lack of any explicit Content-Type metadata when it is used to label a potential media resource.

반대의 경우에 대한 명세가 없으므로 마임 타입 "application/octet-stream"을 "application/octet-stream;codecs=theora" 처럼 매개변수와 함께 쓰면 렌더링 할 수 없음을 사용자 에이전트가 알고 있는 타입입니다. codecs=theora 매개변수는 application/octet-stream과 함께 쓰도록 정의된 것이 아니기 때문입니다.

In the absence of a specification to the contrary, the MIME type "application/octet-stream" when used with parameters, e.g. "application/octet-stream;codecs=theora", is a type that the user agent knows it cannot render, since that parameter is not defined for that type.

media . canPlayType(type)

주어진 타입의 미디어 자원을 사용자 에이전트가 재생할 수 있음을 얼마나 확신할 수 있느냐에 기초하여 빈 문자열(부정적 응답) 또는 "maybe", "probably"를 반환합니다.

Returns the empty string (a negative response), "maybe", or "probably" based on how confident the user agent is that it can play media resources of the given type.

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 요소를 사용할지 아니면 플러그인을 사용할지 동적으로 결정하는 것을 테스트합니다.

This script tests to see if the user agent supports a (fictional) new format to dynamically decide whether to use a video element or a plugin:

<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 Plug-in" 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 속성을 보고 자신이 렌더링할 수 없는 자원이라면 다운로드 하지 않을 수 있습니다.

The type attribute of the source element allows the user agent to avoid downloading resources that use formats it cannot render.

4.8.10.4 네트워크 상태
media . networkState

아래 목록의 코드들로부터 요소에 대한 현재 네트워크 상황을 반환합니다.

Returns the current state of network activity for the element, from the codes in the list below.

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 (numeric value 0)

요소가 아직 초기화되지 않았습니다. 모든 속성들은 초기 상태에 머물러 있습니다.

The element has not yet been initialized. All attributes are in their initial states.

NETWORK_IDLE (numeric value 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 (numeric value 2)

데이터를 내려받으려고 시도하고 있습니다.

The user agent is actively trying to download data.

NETWORK_NO_SOURCE (numeric value 3)

요소의 자원 선택 알고리즘이 활성화되어 있지만 사용할 자원을 찾아내는데 실패하였습니다.

The element's resource selection algorithm is active, but it has so 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.8.10.5 미디어 자원 로딩
media . load()

요소를 리셋하고 새로운 미디어 자원을 다시 로드합니다.

Causes the element to reset and start selecting and loading a new media resource from scratch.

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.

    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. If a fetching process is in progress for the media element, the user agent should stop it.

    2. Set the networkState attribute to NETWORK_EMPTY.

    3. Forget the media element's media-resource-specific text 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 to true.

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

    7. Set the current playback position to 0.

      If this changed the current 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.

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

  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 networkState to NETWORK_NO_SOURCE.

  2. 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 ⌛.)

  3. ⌛ 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.

  4. ⌛ Set the media element's delaying-the-load-event flag to true (this delays the load event), and set its networkState to NETWORK_LOADING.

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

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

    1. Process candidate: If the src attribute's value is the empty string, then end the synchronous section, and jump down to the failed 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: Reaching this step indicates that the media resource failed to load or that the given URL could not be resolved. In one atomic operation, run the following steps:

      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 text tracks.

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

    7. Queue a task to fire a simple event named error at the media element.

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

    9. 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 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 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 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 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: Queue a task to fire a simple event named error at the candidate element, in the context of the fetching process that was used to try to obtain candidate's corresponding media resource in the resource fetch algorithm.

    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 text 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 delaying-the-load-event flag to false. This stops delaying the load event.

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

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

    22. 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 ⌛.)

    23. ⌛ 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).

    24. ⌛ Set the networkState back to NETWORK_LOADING.

    25. ⌛ 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. Begin to fetch the current media resource, from the media element's Document's origin, with the force same-origin flag set.

    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, or while waiting for user input in an interactive resource. When a media element's download has been suspended, the user agent must set the networkState to NETWORK_IDLE and queue a task to fire a simple event named suspend at the element. If and when downloading of the resource resumes, the user agent must set the networkState to NETWORK_LOADING.

    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.

    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 resource is found to have Content-Type metadata that, when parsed as a MIME type (including any codecs described by the codecs parameter, if the parameter is defined for that type), represents a type that the user agent knows it cannot render (even if the actual media data is in a supported format)
    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.

    Once enough of the media data has been fetched to determine the duration of the media resource, its dimensions, and other metadata, and once the text tracks are ready

    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 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. Set the readyState attribute to HAVE_METADATA.

    6. For video elements, set the videoWidth and videoHeight attributes.

    7. 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.

    8. 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 then seek seek to that time. Ignore any resulting exceptions (if the position is out of range, it is effectively ignored).

      For example, a fragment identifier could be used to indicate a start position.

    9. 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, causing the networkState attribute to switch to the NETWORK_IDLE value.

    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)

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

    If the connection is interrupted, 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 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. Queue a task to 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 and queue a task to 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 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. Queue a task to 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 and queue a task to 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 navigated the browsing context to another page, 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. Queue a task to 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 and queue a task to 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 resource's origin is the same origin as the media element's Document's origin, queue a task to run the steps to expose a media-resource-specific text track with the relevant data.

    Cross-origin files do not expose their subtitles in the DOM, for security reasons. However, user agents may still provide the user with access to such data in their user interface.

    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 dispatching a stalled event, as described earlier.

  3. 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.


preload 속성은 나열 속성입니다. 다음의 테이블은 키워드와 상태를 나열합니다.

The preload attribute is an enumerated attribute. The following table lists the keywords and states for the attribute — the keywords in the left column map to the states in the cell in the second column on the same row as the keyword.

Keyword State Brief description
none None

페이지의 저자가 사용자가 이 미디어 자원을 필요로 할 것을 예상하지 못했거나, 서버에서 네트워크 트래픽을 최소화하기를 원하는 경우입니다.

Hints to the user agent that either the author does not expect the user to need the media resource, or that the server wants to minimise unnecessary traffic.

metadata Metadata

페이지의 저자가 사용자가 이 미디어 자원을 필요로 할 것을 예상하지 못하였지만 자원의 메타데이터(크기, 첫 프레임, 트랙 리스트, 길이 등)을 가져오는 것이 의미가 있는 경우입니다.

Hints to the user agent that the author does not expect the user to need the media resource, but that fetching the resource metadata (dimensions, first frame, track list, duration, etc) is reasonable.

auto Automatic

사용자 에이전트가 서버에 위험을 초래하지 않고 사용자의 요구를 우선하여 자원 전체를 최적으로 다운로딩 하는 경우를 포함합니다.

Hints to the user agent that the user agent can put the user's needs first without risk to the server, up to and including optimistically downloading the entire resource.

빈 문자열 역시 유효한 키워드이며, Automatic 상태와 연관됩니다. 속성을 생략했을 경우의 기본값은 사용자 에이전트의 재량이지만 metadata 상태를 권장합니다. 이 상태를 사용하면 괜찮은 수준의 사용자 경험과 경감된 서버 부담 사이에 균형을 가질 수 있습니다.

The empty string is also a valid keyword, and maps to the Automatic state. The attribute's missing value default is user-agent defined, though the Metadata state is suggested as a compromise between reducing server load and providing an optimal user experience.

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.

autoplay 속성은 preload 속성을 덮어 쓸 수 있습니다. (미디어가 재생된다면, 당연히 preload 속성으로 주어진 힌트와 관계 없이 가장 먼저 버퍼링을 하게 됩니다.) 하지만 두 속성 모두 사용해도 에러는 아닙니다.

The autoplay attribute can override the preload attribute (since if the media plays, it naturally has to buffer first, regardless of the hint given by the preload attribute). Including both is not an error, however.


media . buffered

사용자 에이전트가 버퍼링한 미디어 자원의 범위를 나타내는 TimeRanges 객체를 반환합니다.

Returns a TimeRanges object that represents the ranges of the media resource that the user agent has buffered.

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.8.10.6 미디어 자원으로의 오프셋
media . duration

미디어 자원의 길이를 초 단위로 반환합니다. 미디어 자원이 시작하는 위치를 0 초로 간주합니다.

Returns the length of the media resource, in seconds, assuming that the start of the media resource is at time zero.

길이를 알 수 없다면 NaNNot a Number을 반환합니다.

Returns NaN if the duration isn't available.

제한되지 않은 스트림에선 Infinity를 반환합니다. 역주

Returns Infinity for unbounded streams.

media . currentTime [ = value ]

현재의 재생 위치를 초 단위로 반환합니다.

Returns the current playback position, in seconds.

주어진 시간을 탐색하도록 설정할 수 있습니다.

Can be set, to seek to the given time.

선택된 미디어 자원이 없다면 INVALID_STATE_ERR 예외를 반환합니다. 주어진 시간이 사용자 에이전트가 탐색할 수 있는 범위 바깥에 있다면 INDEX_SIZE_ERR 예외를 반환합니다.

Will throw an INVALID_STATE_ERR exception if there is no selected media resource. Will throw an INDEX_SIZE_ERR exception if the given time is not within the ranges to which the user agent can seek.

media . initialTime

미디어 자원을 로드했을 때의 초기 위치인 재생 시작 위치를 반환합니다. 재생 시작 위치를 알 수 없다면 0을 반환합니다.

Returns the initial playback position, that is, time to which the media resource was automatically seeked when it was loaded. Returns zero if the initial playback position is still unknown.

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, 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 startOffsetTime attribute.

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 absence of an explicit timeline, the zero time on the media timeline should correspond to the first frame of the media resource. For static audio and video files this is generally trivial. For streaming resources, if the user agent will 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).

Another example would be 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. 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 startOffsetTime attribute 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 startOffsetTime attribute would return a Date object with a time corresponding to 2010-03-20 23:20:00 UTC.

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.

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.

The currentTime attribute must, on getting, return the current playback position, expressed in seconds. On setting, the user agent must seek to the new value (which might raise an exception).

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.

The initialTime attribute must, on getting, return the initial playback position, expressed in seconds.

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.

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 known to be unbounded (e.g. a streaming radio), 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 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 startOffsetTime attribute must return a new Date object representing the current timeline offset.


loop 속성은 불리언 속성입니다. 속성을 사용하면 미디어 자원의 재생이 종료되는 시점에서 미디어 요소가 자원의 처음으로 되돌아가게 됩니다.

The loop attribute is a boolean attribute that, if specified, indicates that the media element is to seek back to the start of the media resource upon reaching the end.

The loop IDL attribute must reflect the content attribute of the same name.

4.8.10.7 "준비됨" 상태
media . readyState

현재의 재생 위치를 렌더링하는 것과 관련해서 요소의 현재 상태를 반환합니다.

Returns a value that expresses the current state of the element with respect to rendering the current playback position, from the codes in the list below.

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 (numeric value 0)

미디어 자원에 관한 정보나 현재의 재생 위치에 대한 데이터가 없습니다. networkState 속성이 NETWORK_EMPTY로 설정된 미디어 요소는 항상 HAVE_NOTHING 상태입니다.

No information regarding the media resource is available. No data for the current playback position is available. Media elements whose networkState attribute are set to NETWORK_EMPTY are always in the HAVE_NOTHING state.

HAVE_METADATA (numeric value 1)

미디어의 재생 시간에 해당하는 충분한 자원을 가져왔습니다. video 요소라면 비디오의 크기 역시 알고 있습니다. 탐색을 시도해도 API에서 예외를 반환하지는 않을 것입니다. 현재의 재생 위치에 대한 미디어 데이터는 없습니다. 텍스트 트랙준비되었습니다.

Enough of the resource has been obtained that the duration of the resource is available. In the case of a video element, the dimensions of the video are also available. The API will no longer raise an exception when seeking. No media data is available for the immediate current playback position. The text tracks are ready.

HAVE_CURRENT_DATA (numeric value 2)

현재의 재생 위치에 대한 정보를 갖고 있지만, 사용자 에이전트가 즉시 HAVE_METADATA 상태로 전환하지 않고는 재생 방향에서부터 현재의 재생 위치로 이동할 수 있는 정보는 전혀 갖고 있지 못한 경우, 또는 재생 방향에서는 더 이상의 정보를 얻을 수 없는 경우입니다. 예를 들어 비디오에서 사용자 에이전트가 현재의 프레임에 대한 정보는 갖고 있지만 다음 프레임에 대한 정보는 갖고 있지 못한 경우입니다. 또한, 재생이 종료된 경우도 이에 해당합니다.

Data for the immediate current playback position is available, but either not enough data is available that the user agent could successfully advance the current playback position in the direction of playback at all without immediately reverting to the HAVE_METADATA state, or there is no more data to obtain in the direction of playback. For example, in video this corresponds to the user agent having data from the current frame, but not the next frame; and to when playback has ended.

HAVE_FUTURE_DATA (numeric value 3)

현재의 재생 위치에 대한 정보를 갖고 있고 HAVE_METADATA 상태로 즉시 전환하지 않더라도 재생 방향으로 진행하기에 충분한 데이터를 가지고 있는 경우입니다. 예를 들어 비디오에서 사용자 에이전트가 최소한 현재의 프레임과 다음의 프레임에 대한 정보를 갖고 있는 경우입니다. 재생이 완료되었다현재의 재생 위치에서 진행할 수 없으므로 사용자 에이전트는 이 상태에 있을 수 없습니다.

Data for the immediate current playback position is available, as well as enough data for the user agent to advance the current playback position in the direction of playback at least a little without immediately reverting to the HAVE_METADATA state. For example, in video this corresponds to the user agent having data for at least the current frame and the next frame. The user agent cannot be in this state if playback has ended, as the current playback position can never advance in this case.

HAVE_ENOUGH_DATA (numeric value 4)

HAVE_FUTURE_DATA에 해당하는 모든 조건들이 일치하고, 이에 더해 사용자 에이전트는 defaultPlaybackRate 속성에 주어진 재생속도로 현재의 재생 위치부터 진행할 경우 미디어 자원의 끝까지 재생할 때 까지 이에 충분한 비율로 데이터를 가져오고 있다고 판단하는 경우입니다.

All the conditions described for the HAVE_FUTURE_DATA state are met, and, in addition, the user agent estimates that data is being fetched at a rate where the current playback position, if it were to advance at the rate given by the defaultPlaybackRate attribute, would not overtake the available data before playback reaches the end of the media resource.

When the ready state of a media element whose networkState is not NETWORK_EMPTY changes, the user agent must follow the steps given below:

If the previous ready state was HAVE_NOTHING, and the new ready state is HAVE_METADATA

A loadedmetadata DOM event will be fired as part of the load() algorithm.

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

A waiting DOM event can be fired, depending on the current state of playback.

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.

If the element is potentially playing, the user agent must queue a task to fire a simple event named playing.

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, and, if the element is also potentially playing, queue a task to fire a simple event named playing.

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 browsing context did not have the sandboxed automatic features browsing context flag set when the Document was created, then the user agent may also set the paused attribute to false, queue a task to fire a simple event named play, and queue a task to fire a simple event named playing.

User agents are not required to 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.

미디어 요소의 준비 상태가 이러한 상태들 사이를 비연속적으로 이동하는 것이 가능합니다. 예를 들어 미디어 요소의 상태는 HAVE_METADATA에서, HAVE_CURRENT_DATA 상태나 HAVE_FUTURE_DATA 상태를 거치지 않고 HAVE_ENOUGH_DATA로 이동할 수 있습니다.

It is possible for the ready state of a media element to jump between these states discontinuously. For example, the state of a media element can jump straight from HAVE_METADATA to HAVE_ENOUGH_DATA without passing through the HAVE_CURRENT_DATA and HAVE_FUTURE_DATA states.

The readyState IDL attribute must, on getting, return the value described above that describes the current ready state of the media element.

autoplay 속성은 불리언 속성입니다. 이 속성을 사용하면 사용자 에이전트는 미디어 자원을 멈춤 없이 재생할 수 있게 되자마자 재생을 시작할 것입니다.

The autoplay attribute is a boolean attribute. 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 속성을 사용하기를 권장합니다. 이렇게 하면, 사용자는 자신이 원하지 않을 경우 - 예를 들어 스크린 리더 - 자동 재생 옵션을 덮어쓸 수 있습니다. 이에 더해 자동 재생을 아예 사용하지 않기를 권합니다. 그렇게 하는 것 보다, 사용자가 명시적으로 재생을 시작하도록 기다리는 편이 좋습니다. 역주

Authors are urged to use the autoplay attribute rather than using script to trigger automatic playback, as this allows the user to override the automatic playback when it is not desired, e.g. when using a screen reader. Authors are also encouraged to consider not using the automatic playback behavior at all, and instead to let the user agent wait for the user to start playback explicitly.

The autoplay IDL attribute must reflect the content attribute of the same name.

4.8.10.8 미디어 자원 재생
media . paused

재생이 일시 정지되었으면 true, 그렇지 않으면 false를 반환합니다.

Returns true if playback is paused; false otherwise.

media . ended

미디어 자원의 끝까지 재생했다면 true를 반환합니다.

Returns true if playback has reached the end of the media resource.

media . defaultPlaybackRate [ = value ]

재생의 기본 속도, 즉 사용자가 빨리감기를 하거나 되감기를 하지 않을 경우의 속도를 반환합니다.

Returns the default rate of playback, for when the user is not fast-forwarding or reversing through the media resource.

기본 속도를 설정할 수 있습니다.

Can be set, to change the default rate of playback.

기본 속도는 재생에 직접적인 영향을 끼치지는 않습니다. 사용자가 빨리감기 모드로 전환했다가 정상 재생으로 돌아올 경우, 기본 속도가 사용될 것으로 간주합니다.

The default rate has no direct effect on playback, but if the user switches to a fast-forward mode, when they return to the normal playback mode, it is expected that the rate of playback will be returned to the default rate of playback.

media . playbackRate [ = value ]

현재의 재생 속도를 반환합니다. 기본 속도는 1.0입니다.

Returns the current rate playback, where 1.0 is normal speed.

재생 속도를 설정할 수 있습니다.

Can be set, to change the rate of playback.

media . played

사용자 에이전트가 재생한 미디어 자원의 범위를 나타내는 TimeRanges 객체를 반환합니다.

Returns a TimeRanges object that represents the ranges of the media resource that the user agent has played.

media . play()

paused 속성을 false로 설정하고 미디어 자원을 로드한 후 필요하다면 재생합니다. 재생이 완료된 상태라면 처음부터 재시작할 것입니다.

Sets the paused attribute to false, loading the media resource and beginning playback if necessary. If the playback had ended, will restart it from the start.

media . pause()

paused 속성을 true로 설정하고, 필요하다면 미디어 자원을 로드합니다.

Sets the paused attribute to true, loading the media resource if necessary.

The paused attribute represents whether the media element is paused or not. The attribute must initially be true.

A media element is said to be potentially playing when its paused attribute is false, the readyState attribute is either HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA, the element has not ended playback, playback has not stopped due to errors, and the element has not paused for user interaction.

A media element is said to have ended playback when the element's readyState attribute is HAVE_METADATA or greater, and either the current playback position is the end of the media resource and the direction of playback is forwards and the media element does not have a loop attribute specified, or the current playback position is the earliest possible position and the direction of playback is backwards.

The ended attribute must return true if the media element has ended playback and the direction of playback is 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.

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.

When a media element that is potentially playing stops playing because its readyState attribute changes to a value lower than HAVE_FUTURE_DATA, without the element having ended playback, or playback having stopped due to errors, or playback having paused for user interaction, or the seeking algorithm being invoked, 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.

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, then seek to the earliest possible position of the media resource and abort these steps.

  2. Stop playback.

    The ended attribute becomes true.

  3. The user agent must queue a task to fire a simple event named timeupdate at the element.

  4. The user agent must queue a task to fire a simple event named ended at the element.

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 follow these steps:

  1. Stop playback.

  2. The user agent must 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 playbackRate attribute gives 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 must change speed (if the element is potentially playing).

If the playbackRate is positive or zero, then the direction of playback is forwards. Otherwise, it is backwards.

The "play" function in a user agent's interface must set the playbackRate attribute to the value of the defaultPlaybackRate attribute before invoking the play() method's steps. Features such as fast-forward or rewind must be implemented by only changing the playbackRate attribute.

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 played attribute must return a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent has so far rendered, 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, 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's paused attribute is true, run the following substeps:

    1. Change the value of paused to false.

    2. Queue a task to fire a simple event named play at the element.

    3. 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.

  4. Set the media element's autoplaying flag to false.


When the pause() method 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. 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.


When a media element is potentially playing and its Document is a fully active Document, its current playback position must increase monotonically at playbackRate units of media time per unit time of wall clock time.

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.

When the playbackRate is negative (playback is backwards), any corresponding audio must be muted. When the playbackRate is so low or so high that the user agent cannot play audio usefully, the corresponding audio must also be muted. If the playbackRate is not 1.0, the user agent may apply pitch adjustments to the audio as necessary to render it faithfully.

The playbackRate 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).

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 to which no references exist has reached a point where no further audio remains to be played for that element (e.g. because the element is paused, or because the end of the clip has been reached, or because its playbackRate is 0.0) may the element be garbage collected.


When the current playback position of a media element changes (e.g. due to playback or seeking), the user agent must run the following 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".)

  1. Let current cues be an ordered list of cues, initialized to contain all the cues of all the hidden, showing, or showing by default 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, in text track cue order.

  2. Let other cues be an ordered list of cues, initialized to contain all the cues of hidden, showing, and showing by default text tracks of the media element that are not present in current cues, also in text track cue order.

  3. 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.

  4. If all of the cues in current cues have their text track cue active flag set, and none of the cues in other cues have their text track cue active flag set, then abort these steps.

  5. 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 both their text track cue active flag set and their text track cue pause-on-exit flag set, then immediately act as if the element's pause() method had been invoked. (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.)

  6. Let affected tracks be a list of text tracks, initially empty.

  7. For each text track cue in other cues that has its text track cue active flag set, in list order, queue a task to fire a simple event named exit at the TextTrackCue object, and add the cue's text track to affected tracks, if it's not already in the list.

  8. For each text track cue in current cues that does not have its text track cue active flag set, in list order, queue a task to fire a simple event named enter at the TextTrackCue object, and add the cue's text track to affected tracks, if it's not already in the list.

  9. For each text track in affected tracks, in the order they were added to the list (which will match the relative order of the text tracks in the media element's list of text tracks), 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.

  10. 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.

  11. Run the rules for updating the text track rendering of each of the text tracks in affected tracks that are showing or showing by default.

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.

When a media element is removed from a Document, if the media element's networkState attribute has a value other than NETWORK_EMPTY then the user agent must act as if the pause() method had been invoked.

If the media element's Document stops being a fully active document, then the playback will stop until the document is active again.

4.8.10.9 탐색
media . seeking

사용자 에이전트가 현재 탐색중일 경우 true를 반환합니다.

Returns true if the user agent is currently seeking.

media . seekable

사용자 에이전트가 탐색할 수 있는 범위를 나타내는 TimeRanges 객체를 반환합니다.

Returns a TimeRanges object that represents the ranges of the media resource to which it is possible for the user agent to seek.

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, 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. If the media element's readyState is HAVE_NOTHING, then raise an INVALID_STATE_ERR exception (if the seek was in response to a DOM method call or setting of an IDL attribute), and abort these steps.

  2. 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.

  3. Set the seeking IDL attribute to true.

  4. 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.

  5. 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.

  6. If the new playback position is less than the earliest possible position, let it be that position instead.

  7. 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.

  8. Set the current playback position to the given new playback position.

  9. Queue a task to fire a simple event named seeking at the element.

  10. Queue a task to fire a simple event named timeupdate at the element.

  11. 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 queue a task to fire a simple event named waiting at the element.

  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. 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).

4.8.10.10 시간이 설정된 텍스트 트랙
4.8.10.10.1 텍스트 트랙 모델

미디어 요소는 연관된 텍스트 트랙의 그룹을 가질 수 있으며 이러한 것을 텍스트 트랙 목록이라 부릅니다. 텍스트 트랙은 다음과 같이 정렬합니다.

A media element can have a group of associated text tracks, known as the media element's list of text tracks. The text tracks are sorted as follows:

  1. 미디어 요소의 자식 요소인 track 요소에 대응하는 텍스트 트랙들을 트리 순서로.

    The text tracks corresponding to track element children of the media element, in tree order.

  2. addTrack() 메서드를 이용해 추가된 모든 텍스트 트랙을 추가된 순서대로.

    Any text tracks added using the addTrack() method, in the order they were added, oldest first.

  3. 미디어 자원에 특화된 텍스트 트랙 모두(미디어 자원의 데이터에 대응하는 텍스트 트랙), 미디어 자원 포맷의 명세에 정의된 순서대로

    Any media-resource-specific text tracks (text tracks corresponding to data in the media resource), in the order defined by the media resource's format specification.

텍스트 트랙은 다음으로 구성됩니다.

A text track consists of:

텍스트 트랙의 종류 The kind of text track

사용자 에이전트가 이 트랙을 어떻게 다룰 지 정합니다. 종류는 문자열로 표현하며, 다음과 같은 값을 가질 수 있습니다.

This decides how the track is handled by the user agent. The kind is represented by a string. The possible strings are:

track 요소에 대응하는 텍스트 트랙종류는 동적으로 바뀔 수 있습니다.

The kind of track can change dynamically, in the case of a text track corresponding to a track element.

레이블 A label

사용자가 트랙을 식별할 수 있게끔 제공하는 사람이 읽을 수 있는 문자열입니다. 이 레이블을 자동으로 생성하는 경우도 있습니다.

This is a human-readable string intended to identify the track for the user. In certain cases, the label might be generated automatically.

track 요소에 대응하는 텍스트 트랙이거나 사용자의 인터페이스 언어 등 다양한 요소를 기준으로 레이블을 자동으로 생성한다면 트랙의 레이블을 동적으로 바꿀 수 있습니다.

The label of a track can change dynamically, in the case of a text track corresponding to a track element or in the case of an automatically-generated label whose value depends on variable factors such as the user's preferred user interface language.

언어 A language

텍스트 트랙의 큐에 사용된 언어를 표현한 BCP 47 언어 태그 문자열입니다. [BCP47]

This is a string (a BCP 47 language tag) representing the language of the text track's cues. [BCP47]

track 요소에 대응하는 텍스트 트랙이라면 텍스트 트랙의 언어를 동적으로 바꿀 수 있습니다.

The language of a text track can change dynamically, in the case of a text track corresponding to a track element.

준비 상태 A readiness state

다음 중 하나입니다.

One of the following:

Not loaded

텍스트 트랙이 존재함을 알고 있지만(예를 들어, track 요소에서 선언하였으므로), 아직 큐를 가져오지 못했습니다.

Indicates that the text track is known to exist (e.g. it has been declared with a track element), but its cues have not been obtained.

Loading

텍스트 트랙을 가져오고 있으며 아직은 중대한 오류가 발생하지 않았습니다. 트랙에 더 많은 큐를 추가할수도 있습니다.

Indicates that the text track is loading and there have been no fatal errors encountered so far. Further cues might still be added to the track.

Loaded

중대한 오류 없이 텍스트 트랙을 가져왔음을 나타냅니다. 텍스트 트랙MutableTextTrack 객체에 대응하는 경우를 제외하면 더이상 큐를 가져오지 않을 것입니다.

Indicates that the text track has been loaded with no fatal errors. No new cues will be added to the track except if the text track corresponds to a MutableTextTrack object.

Failed to load

텍스트 트랙이 활성화되었지만 사용자 에이전트가 텍스트 트랙을 가져오려는 중 어떤 이유(예를 들어 URL해석할 수 없었거나, 네트워크 문제가 있었거나, 텍스트 트랙의 포맷을 알 수 없거나)로 인해 실패했음을 나타냅니다. 큐의 일부 혹은 전부를 잃어버렸을 수 있으며 가져오지 못합니다.

Indicates that the text track was enabled, but when the user agent attempted to obtain it, this failed in some way (e.g. URL could not be resolved, network error, unknown text track format). Some or all of the cues are likely missing and will not be obtained.

텍스트 트랙준비 상태는 트랙을 가져옴에 따라 동적으로 변합니다.

The readiness state of a text track changes dynamically as the track is obtained.

모드 A mode

다음 중 하나입니다.

One of the following:

Disabled

텍스트 트랙이 활성이 아님을 나타냅니다. 사용자 에이전트는 이 트랙을 DOM에 노출하는 것 이외에는 트랙을 무시하고 있습니다. 활성인 큐가 없고 아무런 이벤트도 발생하지 않았으며 사용자 에이전트는 트랙의 큐를 가져오려는 시도를 하지 않을 것입니다.

Indicates that the text track is not active. Other than for the purposes of exposing the track in the DOM, the user agent is ignoring the text track. No cues are active, no events are fired, and the user agent will not attempt to obtain the track's cues.

Hidden

텍스트 트랙이 활성이지만 사용자 에이전트는 큐를 표시하지 않고 있습니다. 아직 트랙의 큐를 가져오려는 시도를 하지 않았다면 사용자 에이전트는 순간적으로 그러한 시도를 할 것입니다. 사용자 에이전트는 활성인 큐의 목록을 관리하고 있으며 이에 대응하는 이벤트들이 발생하고 있습니다.

Indicates that the text track is active, but that the user agent is not actively displaying the cues. If no attempt has yet been made to obtain the track's cues, the user agent will perform such an attempt momentarily. The user agent is maintaining a list of which cues are active, and events are being fired accordingly.

Showing
Showing by default

텍스트 트랙이 활성임을 나타냅니다. 아직 트랙의 큐를 가져오려는 시도를 하지 않았다면 사용자 에이전트는 순간적으로 그러한 시도를 할 것입니다. 사용자 에이전트는 활성인 큐의 목록을 관리하고 있으며 이에 대응하는 이벤트들이 발생하고 있습니다. 트랙의 종류subtitles 또는 captions 라면 큐는 적당한 방법으로 비디오 위에 표현됩니다. 트랙의 종류descriptions 라면 사용자 에이전트는 사용자가 큐를 사용할 수는 있지만 보이지는 않게 할 것입니다. 트랙의 종류chapters 인 경우 사용자 에이전트는 사용자가 큐를 선택함으로서 미디어 자원의 대응하는 지점으로 이동할 수 있게끔 하는 메커니즘을 제공할 것입니다.

Indicates that the text track is active. If no attempt has yet been made to obtain the track's cues, the user agent will perform such an attempt momentarily. The user agent is maintaining a list of which cues are active, and events are being fired accordingly. In addition, for text tracks whose kind is subtitles or captions, the cues are being displayed over the video as appropriate; for text tracks whose kind is descriptions, the user agent is making the cues available to the user in a non-visual fashion; and for text tracks whose kind is chapters, the user agent is making available to the user a mechanism by which the user can navigate to any point in the media resource by selecting a cue.

showing by default 상태를 default 속성과 함께 사용하면 텍스트 트랙이 default 속성에 의해 활성화되었음을 나타냅니다. 사용자 에이전트는 이러한 것을 이용해서 다음 트랙이 사용자의 선호에 더 적합한 경우 그 상태를 덮어쓸 수 있습니다.

The showing by default state is used in conjunction with the default attribute on track elements to indicate that the text track was enabled due to that attribute. This allows the user agent to override the state if a later track is discovered that is more appropriate per the user's preferences.

0개 이상의 큐로 구성된 목록 A list of zero or more cues

텍스트 트랙의 큐 목록입니다. 텍스트 트랙 렌더링을 갱신하는 규칙과 함께 제공됩니다.

A list of text track cues, along with rules for updating the text track rendering.

텍스트 트랙 큐의 목록은 동적으로 변할 수 있습니다. 그러한 변화는 텍스트 트랙아직 로드되지 않았거나, 로드 중이거나, 개별적인 큐를 동적으로 추가하거나 제거하는 API를 제공하는 MutableTextTrack 객체에 대응하는 경우 발생합니다.

The list of cues of a text track can change dynamically, either because the text track has not yet been loaded or is still loading, or because the text track corresponds to a MutableTextTrack object, whose API allows individual cues can be added or removed dynamically.

각각의 텍스트 트랙은 그에 대응하는 TextTrack 객체를 갖습니다.

Each text track has a corresponding TextTrack object.

미디어 요소텍스트 트랙은 다음 상황에서 준비됨 상태가 됩니다: 요소의 자원 선택 알고리즘을 마지막으로 시작한 시점에서 disabled 모드였던 트랙을 제외한 모든 텍스트 트랙텍스트 트랙 준비 상태로드됨 또는 로드 실패가 되는 시점.

The text tracks of a media element are ready if all the text tracks whose mode was not in the disabled state when the element's resource selection algorithm last started now have a text track readiness state of loaded or failed to load.


텍스트 트랙 큐텍스트 트랙에 포함된, 특정 시간에 나타나고 다른 특정 시간에 사라지는 자막과 캡션에 대응하는, 시간에 민감한 데이터 단위입니다.

A text track cue is the unit of time-sensitive data in a text track, corresponding for instance for subtitles and captions to the text that appears at a particular time and disappears at another time.

각각의 텍스트 트랙 큐는 다음으로 구성됩니다.

Each text track cue consists of:

식별자 An identifier

인위적인 문자열입니다.

An arbitrary string.

시작 시간 A start time

초와 그 분할로 나타낸 시간입니다. 이 시점에서 큐가 연결됩니다.

A time, in seconds and fractions of a second, at which the cue becomes relevant.

종료 시간 An end time

초와 그 분할로 나타낸 시간입니다. 이 시점에서 큐의 연결이 끝납니다.

A time, in seconds and fractions of a second, at which the cue stops being relevant.

종료시 정지 플랙 A pause-on-exit flag

관련된 큐가 멈췄을때 미디어 자원의 재생을 일시정지할지를 나타내는 불리언입니다. 역주

A boolean indicating whether playback of the media resource is to pause when the cue stops being relevant.

기록 방향 A writing direction

가로 - 줄은 가로로 늘어나면서 세로로 위치합니다. 즉, 이어지는 줄이 그 아래에 표시됩니다 - 또는 왼쪽으로 진행하는 세로 - 줄은 세로로 늘어나면서 가로로 위치합니다. 즉, 이어지는 줄이 그 왼쪽에 표시됩니다. 동아시아 언어에서 사용됩니다 - 또는 오른쪽으로 진행하는 세로 - 이어지는 줄이 그 오른쪽에 표시됩니다. 몽고어에서 사용됩니다 - 중 하나입니다.

A writing direction, either horizontal (a line extends horizontally and is positioned vertically, with consecutive lines displayed below each other), vertical growing left (a line extends vertically and is positioned horizontally, with consecutive lines displayed to the left of each other), or vertical growing right (a line extends vertically and is positioned horizontally, with consecutive lines displayed to the right of each other).

크기 A size

큐의 텍스트가 정렬될 박스의 크기를 나타내는 숫자입니다. 쓰는 방향에서 정의된 대로 비디오에 대한 퍼센트로 해석합니다.

A number giving the size of the box within which the text of each line of the cue is to be aligned, to be interpreted as a percentage of the video, as defined by the writing direction.

큐 텍스트 The text of the cue

텍스트 데이터와 그 해석 - 텍스트 렌더링과 DOM 삽입 - 에 사용할 규칙입니다.

The raw text of the cue, and rules for its interpretation, allowing the text to be rendered and converted to a DOM fragment.

텍스트 트랙 큐는 변하지 않습니다.

A text track cue is immutable.

각각의 텍스트 트랙 큐는 대응하는 TextTrackCue 객체를 가지며, 텍스트 트랙과 연결될 수 있습니다. 일단 텍스트 트랙 큐가 특정 텍스트 트랙과 연결되면 그 연결은 영구적입니다.

Each text track cue has a corresponding TextTrackCue object, and can be associated with a particular text track. Once a text track cue is associated with a particular text track, the association is permanent.

각각의 텍스트 트랙 큐는 두가지 동적 정보를 갖습니다.

In addition, each text track cue has two pieces of dynamic information:

활성 플랙 The active flag

이 플랙은 초기 단계에서는 설정되지 않아야 합니다. 이 플랙은 큐가 활성/비활성화될 때 이벤트들이 적절하게 발생할 수 있도록 하며 정확한 큐가 렌더링되도록 합니다.

This flag must be initially unset. The flag is used to ensure events are fired appropriately when the cue becomes active or inactive, and to make sure the right cues are rendered.

사용자 에이전트는 다음의 경우마다 이 플랙을 동기적으로 해제해야 합니다: 텍스트 트랙 큐텍스트 트랙큐의 텍스트 트랙 리스트에서 제거될 때, 텍스트 트랙미디어 요소텍스트 트랙 리스트에서 제거되거나 텍스트 트랙 모드disabled로 바뀔 때, 미디어 요소readyStateHAVE_NOTHING으로 바뀔 때. 사용자 에이전트는 showing 또는 showing by default 상태에 있던 텍스트 트랙의 하나 이상의 큐에 대해 플랙이 이런 방법으로 바뀔때마다 관련있는 모든 큐를 해제한 후 그러한 텍스트 트랙들에 텍스트 트랙 렌더링 업데이트 규칙을 적용해야 합니다.

The user agent must synchronously unset this flag whenever the text track cue is removed from its text track's text track list of cues; whenever the text track itself is removed from its media element's list of text tracks or has its text track mode changed to disabled; and whenever the media element's readyState is changed back to HAVE_NOTHING. When the flag is unset in this way for one or more cues in text tracks that were showing or showing by default prior to the relevant incident, the user agent must, after having unset the flag for all the affected cues, apply the rules for updating the text track rendering of those text tracks.

디스플레이 상태 The display state

큐를 일관된 위치에 유지하기 위해 렌더링 모델에서 사용됩니다. 초기에는 비어 있어야 합니다. 사용자 에이전트는 텍스트 트랙 큐 액티브 플랙이 해제될 때마다 텍스트 트랙 큐 디스플레이 상태를 비워야 합니다.

This is used as part of the rendering model, to keep cues in a consistent position. It must initially be empty. Whenever the text track cue active flag is unset, the user agent must empty the text track cue display state.

미디어 요소텍스트 트랙텍스트 트랙 큐텍스트 트랙 큐 순서에 의해 정렬되는데, 그러한 순서는 다음과 같이 결정됩니다. 1) 미디어 요소텍스트 트랙 목록의 순서대로 텍스트 트랙을 정렬한 후 그에 맞게 들을 묶습니다. 2) 각각의 그룹에 대해, 들을 시작 시간 순서대로 정렬합니다. 3) 시작 시간이 같은 들은 종료 시간 순으로 정렬합니다. 4) 종료 시간간까지 동일한 들은 만들어진 순서대로 정렬합니다(따라서, 예를 들어, WebVTT 파일에서 생성한 는 그 파일에 들어있던 순서가 될 것입니다)

The text track cues of a media element's text tracks are ordered relative to each other in the text track cue order, which is determined as follows: first group the cues by their text track, with the groups being sorted in the same order as their text tracks appear in the media element's list of text tracks; then, within each group, cues must be sorted by their start time, earliest first; then, any cues with the same start time must be sorted by their end time, earliest first; and finally, any cues with identical end times must be sorted in the order they were created (so e.g. for cues from a WebVTT file, that would be the order in which the cues were listed in the file).

4.8.10.10.2 Sourcing in-band text tracks

미디어 자원에 특정한 텍스트 트랙이란 그 미디어 자원의 데이터에 대응하는 텍스트 트랙입니다.

A media-resource-specific text track is a text track that corresponds to data found in the media resource.

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 by the relevant specification.

  3. Populate the new text track's list of cues with the cues parsed so far, folllowing the guidelines for exposing cues, and begin updating it dynamically as necessary.

  4. Set the new text track's readiness state to the value that most correctly describes the current state, and begin updating it dynamically as necessary.

    For example, if the relevant data in the media resource has been fully parsed and completely describes the cues, then the text track would be loaded. On the other hand, if the data for the cues is interleaved with the media data, and the media resource as a whole is still being downloaded, then the loading state might be more accurate.

  5. 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.

  6. Leave the text track list of cues empty, and associate with it the rules for updating the text track rendering appropriate for the format in question.

  7. Add the new text track to the media element's list of text tracks.

When a media element is to forget the media element's media-resource-specific text tracks, the user agent must remove from the media element's list of text tracks all the media-resource-specific text tracks.

4.8.10.10.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:

State String
Subtitles subtitles
Captions captions
Descriptions 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 added, removed, or changed, 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 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.

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.

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.

When a text track corresponding to a track element is added to a media element's list of text tracks, the user agent must set the text track mode appropriately, as determined by the following conditions:

If the text track kind is subtitles or captions and the user has indicated an interest in having a track with this text track kind, text track language, and text track label enabled, and there is no other text track in the media element's list of text tracks with a text track kind of either subtitles or captions whose text track mode is showing
If the text track kind is descriptions and the user has indicated an interest in having text descriptions with this text track language and text track label enabled, and there is no other text track in the media element's list of text tracks with a text track kind of descriptions whose text track mode is showing
If the text track kind is chapters and the text track language is one that the user agent has reason to believe is appropriate for the user, and there is no other text track in the media element's list of text tracks with a text track kind of chapters whose text track mode is showing

Let the text track mode be showing.

If there is a text track in the media element's list of text tracks whose text track mode is showing by default, the user agent must furthermore change that text track's text track mode to hidden.

If the track element has a default attribute specified, and there is no other text track in the media element's list of text tracks whose text track mode is showing or showing by default

Let the text track mode be showing by default.

Otherwise

Let the text track mode be disabled.

When a text track corresponding to a track element is created with text track mode set to hidden, showing, or showing by default, and when a text track corresponding to a track element is created with text track mode set to disabled and subsequently changes its text track mode to hidden, showing, or showing by default for the first time, the user agent must immediately and synchronously 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 step in that section is marked with ⌛.

  1. Set the text track readiness state to loading.

  2. Let URL be the track URL of the track element.

  3. Asynchronously run the remaining steps, while continuing with whatever task was responsible for creating the text track or changing the text track mode.

  4. Download: If URL is not the empty string, and its origin is the same as the media element's Document's origin, then fetch URL, from the media element's Document's origin, with the force same-origin flag set.

    The tasks queued by the fetching algorithm on the networking task source to process the data as it is being fetched must examine the resource's Content Type metadata, once it is available, if it ever is. If no Content Type metadata is ever available, or if the type is not recognised as a text track format, then the resource's format must be assumed to be unsupported (this causes the load to fail, as described below). If a type is obtained, and represents a supported text track format, then the resource's data must be passed to the appropriate parser as it is received, with the text track list of cues being used for that parser's output.

    If the fetching algorithm fails for any reason (network error, the server returns an error code, a cross-origin check fails, etc), or if URL is the empty string or has the wrong origin as determined by the condition at the start of this step, or if the fetched resource is not in a supported format, then 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; and then, once that task is queued, move on to the step below labeled monitoring.

    If the fetching algorithm does not fail, then, when it completes, queue a task to first change the text track readiness state to loaded and then fire a simple event named load at the track element; and then, once that task is queued, move on to the step below labeled monitoring.

    If, while the fetching algorithm is active, either:

    ...then the user agent must run the following steps:

    1. Abort the fetching algorithm.

    2. Queue a task to fire a simple event named abort at the track element.

    3. Let URL be the new track URL.

    4. Jump back to the top of the step labeled download.

    Until one of the above circumstances occurs, the user agent must remain on this step.

  5. Monitoring: Wait until the track URL is no longer equal to URL, at the same time as the text track mode is set to hidden, showing, or showing by default.

  6. Wait until the text track readiness state is no longer set to loading.

  7. Await a stable state. The synchronous section consists of the following step. (The step in the synchronous section is marked with ⌛.)

  8. ⌛ Set the text track readiness state to loading.

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

  10. Jump to the step labeled download.

4.8.10.10.4 텍스트 트랙 API
media . tracks . length

미디어 요소와 연결된 텍스트 트랙의 갯수를 반환합니다. 미디어 요소텍스트 트랙 목록에 있는 텍스트 트랙의 수와 동일합니다.

Returns the number of text tracks associated with the media element (e.g. from track elements). This is the number of text tracks in the media element's list of text tracks.

media . tracks[ n ]

미디어 요소텍스트 트랙 목록에서 n번째 텍스트 트랙을 나타내는 TextTrack 객체를 반환합니다.

Returns the TextTrack object representing the nth text track in the media element's list of text tracks.

track . track

track 요소의 텍스트 트랙을 나타내는 TextTrack 객체를 반환합니다.

Returns the TextTrack object representing the track element's text track.

The tracks attribute of media elements must return an array host object for objects of type TextTrack that is fixed length and read only. The same object must be returned each time the attribute is accessed. [WEBIDL]

The array must contain 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.


interface TextTrack {
  readonly attribute DOMString kind;
  readonly attribute DOMString label;
  readonly attribute DOMString language;

  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 Function onload;
  readonly attribute Function onerror;

  const unsigned short OFF = 0;
  const unsigned short HIDDEN = 1;
  const unsigned short SHOWING = 2;
           attribute unsigned short mode;

  readonly attribute TextTrackCueList cues;
  readonly attribute TextTrackCueList activeCues;

  readonly attribute Function oncuechange;
};
timedTrack . kind

텍스트 트랙 종류를 나타내는 문자열을 반환합니다.

Returns the text track kind string.

timedTrack . label

텍스트 트랙 레이블을 반환합니다.

Returns the text track label.

timedTrack . language

텍스트 트랙의 언어를 나타내는 문자열을 반환합니다.

Returns the text track language string.

timedTrack . readyState

텍스트 트랙의 준비 상태를 반환합니다. 이 상태는 다음의 목록에서 정의된 숫자로 표현됩니다.

Returns the text track readiness state, represented by a number from the following list:

TextTrack . NONE (0)

The text track not loaded state.

TextTrack . LOADING (1)

The text track loading state.

TextTrack . LOADED (2)

The text track loaded state.

TextTrack . ERROR (3)

The text track failed to load state.

timedTrack . mode

텍스트 트랙 모드를 반환합니다. 다음의 목록에서 정의된 숫자로 표현됩니다.

Returns the text track mode, represented by a number from the following list:

TextTrack . OFF (0)

The text track disabled mode.

TextTrack . HIDDEN (1)

The text track hidden mode.

TextTrack . SHOWING (2)

The text track showing and showing by default modes.

설정하여 모드를 변경할 수 있습니다.

Can be set, to change the mode.

timedTrack . cues

텍스트 트랙의 큐 목록TextTrackCueList 객체로 반환합니다.

Returns the text track list of cues, as a TextTrackCueList object.

timedTrack . activeCues

현재 활성(즉, 현재 재생 위치 앞에서 시작한 것과 그 이후 전부)인 텍스트 트랙 큐 목록으로부터 텍스트 트랙 큐TextTrackCueList 객체로 반환합니다.

Returns the text track cues from the text track list of cues that are currently active (i.e. that start before the current playback position and end after it), as a TextTrackCueList 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 readyState attribute must return the numeric value corresponding to the text track readiness state of the text track that the TextTrack object represents, as defined by the following list:

NONE (numeric value 0)
The text track not loaded state.
LOADING (numeric value 1)
The text track loading state.
LOADED (numeric value 2)
The text track loaded state.
ERROR (numeric value 3)
The text track failed to load state.

The mode attribute, on getting, must return the numeric value corresponding to the text track mode of the text track that the TextTrack object represents, as defined by the following list:

OFF (numeric value 0)
The text track disabled mode.
HIDDEN (numeric value 1)
The text track hidden mode.
SHOWING (numeric value 2)
The text track showing and showing by default modes.

On setting, if the new value is not either 0, 1, or 2, the user agent must throw an INVALID_ACCESS_ERR exception. Otherwise, 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 0

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 1

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 2

Set the text track mode of the text track that the TextTrack object represents to the text track showing mode.

If the mode had been showing by default, this will change it to showing, even though the value of mode would appear not to change.

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 start times occur before 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.


interface MutableTextTrack : TextTrack {
 void addCue(in TextTrackCue cue);
 void removeCue(in TextTrackCue cue);
};
mutableTextTrack = media . addTrack( kind [, label [, language ] ] )

MutableTextTrack 객체를 생성하여 반환합니다. 이 객체는 미디어 요소텍스트 트랙 목록에도 추가됩니다.

Creates and returns a new MutableTextTrack object, which is also added to the media element's list of text tracks.

mutableTextTrack . addCue( cue )

주어진 큐를 mutableTextTrack텍스트 트랙 큐 리스트에 추가합니다.

Adds the given cue to mutableTextTrack's text track list of cues.

매개변수가 null 이거나, 다른 텍스트 트랙과 연결된 것이거나, 이미 큐 목록에 있을 경우 예외를 반환합니다.

Raises an exception if the argument is null, associated with another text track, or already in the list of cues.

mutableTextTrack . removeCue( cue )

주어진 큐를 mutableTextTrack텍스트 트랙 큐 목록에서 제거합니다.

Removes the given cue from mutableTextTrack's text track list of cues.

매개변수가 null 이거나, 다른 텍스트 트랙과 연결된 것이거나, 큐 목록에 없을 경우 예외를 반환합니다.

Raises an exception if the argument is null, associated with another text track, or not in the list of cues.

The addTrack(kind, label, language) method of media elements, when invoked, must run the following steps:

  1. If kind is not one of the following strings, then throw a SYNTAX_ERR exception and abort these steps:

  2. If the label argument was omitted, let label be the empty string.

  3. If the language argument was omitted, let language be the empty string.

  4. Create a new text track, 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.

  5. Add the new text track to the media element's list of text tracks.

The addCue(cue) method of MutableTextTrack objects, when invoked, must run the following steps:

  1. If cue is null, then throw an INVALID_ACCESS_ERR exception and abort these steps.

  2. If the given cue is already associated with a text track other than the method's MutableTextTrack object's text track, then throw an INVALID_STATE_ERR exception and abort these steps.

  3. Associate cue with the method's MutableTextTrack object's text track, if it is not currently associated with a text track.

  4. If the given cue is already listed in the method's MutableTextTrack object's text track's text track list of cues, then throw an INVALID_STATE_ERR exception.

  5. Add cue to the method's MutableTextTrack object's text track's text track list of cues.

The removeCue(cue) method of MutableTextTrack objects, when invoked, must run the following steps:

  1. If cue is null, then throw an INVALID_ACCESS_ERR exception and abort these steps.

  2. If the given cue is not associated with the method's MutableTextTrack object's text track, then throw an INVALID_STATE_ERR exception.

  3. If the given cue is not currently listed in the method's MutableTextTrack object's text track's text track list of cues, then throw a NOT_FOUND_ERR exception.

  4. Remove cue from the method's MutableTextTrack object's text track's text track list of cues.

여러가지 음향 효과를 포함하고 있는 파일로부터 특정한 음향 효과를 재생하기 위해 audio 요소를 사용했습니다. 큐를 사용해서 소리를 일시정지시키면 설령 브라우저가 다른 스크립트를 처리하느라 바쁘더라도 클립이 종료되는 시점에서 정확히 종료됩니다. 페이지에서 오디오를 일시정지시키는 작업을 스크립트에 의존했다면 명시된 정확한 시점에서 브라우저가 해당 스크립트를 실행하지 못해서 다음 클립의 시작 부분 소리가 들렸을수도 있습니다.

In this example, an audio element is used to play a specific sound-effect from a sound file containing many sound effects. A cue is used to pause the audio, so that it ends exactly at the end of the clip, even if the browser is busy running some script. If the page had relied on script to pause the audio, then the start of the next clip might be heard if the browser was not able to run the script at the exact time specified.

var sfx = new Audio('sfx.wav');
var sounds = a.addTrack('metadata');
// add sounds we care about
sounds.addCue(new TextTrackCue('dog bark', 12.783, 13.612, '', '', '', true));
sounds.addCue(new TextTrackCue('kitten mew', 13.612, 15.091, '', '', '', true));

function playSound(id) {
  sfx.currentTime = sounds.getCueById(id).startTime;
  sfx.play();
}

sfx.oncanplaythrough = function () {
  playSound('dog bark');
}
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 (in unsigned long index);
  TextTrackCue getCueById(in DOMString id);
};
cuelist . length

목록에 들어있는 의 숫자를 반환합니다.

Returns the number of cues in the list.

cuelist[index]

목록에서 index에 해당하는 텍스트 트랙 큐를 반환합니다. 큐는 텍스트 트랙 큐 순서로 정렬된 상태입니다.

Returns the text track cue with index index in the list. The cues are sorted in text track cue order.

cuelist . getCueById( id )

텍스트 트랙 큐 식별자id인 첫번째(텍스트 트랙 큐 순서텍스트 트랙 큐 순서 상으로) 텍스트 트랙 큐를 반환합니다.

Returns the first text track cue (in text track cue order) with text track cue identifier id.

매개변수가 빈 문자열이거나 주어진 식별자에 해당하는 큐가 없을 경우 null을 반환합니다.

Returns null if none of the cues have the given identifier or if the argument is the empty string.

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 indicies 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 indicies.

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 {
  readonly attribute TextTrack track;
  readonly attribute DOMString id;

  readonly attribute double startTime;
  readonly attribute double endTime;
  readonly attribute boolean pauseOnExit;


  DOMString getCueAsSource();
  DocumentFragment getCueAsHTML();

  readonly attribute Function onenter;
  readonly attribute Function onexit;
};
cue . track

텍스트 트랙 큐가 속하는 TextTrack 객체가 있다면 그것을 반환합니다. 그러한 것이 없다면 null을 반환합니다.

Returns the TextTrack object to which this text track cue belongs, if any, or null otherwise.

cue . id

텍스트 트랙 큐 식별자를 반환합니다.

Returns the text track cue identifier.

cue . startTime

텍스트 트랙 큐 시작 시간을 초 단위로 반환합니다.

Returns the text track cue start time, in seconds.

cue . endTime

텍스트 트랙 큐 종료 시간을 초 단위로 반환합니다.

Returns the text track cue end time, in seconds.

cue . pauseOnExit

텍스트 트랙 큐의 종료시 정지 플랙이 설정되어 있다면 true를, 아니라면 false를 반환합니다.

Returns true if the text track cue pause-on-exit flag is set, false otherwise.

source = cue . getCueAsSource()

텍스트 트랙 큐 텍스트를 파싱되지 않은 원형으로 반환합니다.

Returns the text track cue text in raw unparsed form.

fragment = cue . getCueAsHTML()

텍스트 트랙 큐 텍스트HTML 요소와 기타 DOM 노드로 파싱한 DocumentFragment 로 반환합니다.

Returns the text track cue text as a DocumentFragment of HTML elements and other DOM nodes.

The track attribute must return the TextTrack object of the text track with which the text track cue that the TextTrackCue object represents is associated, if any; or null otherwise.

The id attribute must return the text track cue identifier of the text track cue that the TextTrackCue object represents.

The startTime attribute must return the text track cue start time of the text track cue that the TextTrackCue object represents, in seconds.

The endTime attribute must return the text track cue end time of the text track cue that the TextTrackCue object represents, in seconds.

The pauseOnExit attribute 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.

The direction attribute must return the text track cue writing direction of the text track cue that the TextTrackCue object represents.

The getCueAsSource() method must return the raw text track cue text.

The getCueAsHTML() method must convert the text track cue text to a DocumentFragment for the media element's Document, using the appropriate rules for doing so.

4.8.10.10.5 이벤트 정의

The following are the event handlers that must be supported, as IDL attributes, by all objects implementing the TextTrack interface:

Event handler Event handler event type
onload load
onerror error
oncuechange cuechange

The following are the event handlers that must be supported, as IDL attributes, by all objects implementing the TextTrackCue interface:

Event handler Event handler event type
onenter enter
onexit exit
4.8.10.11 사용자 인터페이스

controls 속성은 불리언 속성입니다. 저자가 스크립팅한 컨트롤러가 있는 것이 아니라 사용자 에이전트에서 제공하는 컨트롤러를 사용할 것임을 나타냅니다.

The controls attribute is a boolean attribute. If present, it indicates that the author has not provided a scripted controller and would like the user agent to provide its own set of 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.

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.

Where possible (specifically, for starting, stopping, pausing, and unpausing playback, for seeking, 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.

For the purposes of listing chapters in the media resource, only text tracks in the media element's list of text tracks showing or showing by default and whose text track kind is chapters should be used. Each cue in such a text track represents a chapter starting at the cue's start time. The name of the chapter is the text track cue text, interpreted literally.

The controls IDL attribute must reflect the content attribute of the same name.


media . volume [ = value ]

현재의 재생 볼륨을 0.0에서 1.0 사이의 숫자로 반환합니다. 0.0은 가장 작은 볼륨이며 1.0은 가장 큰 볼륨입니다.

Returns the current playback volume, as a number in the range 0.0 to 1.0, where 0.0 is the quietest and 1.0 the loudest.

설정하여 볼륨을 바꿀 수 있습니다.

Can be set, to change the volume.

주어진 값이 0.0 ~ 1.0 사이의 범위가 아닐 경우 INDEX_SIZE_ERR 를 반환합니다.

Throws an INDEX_SIZE_ERR if the new value is not in the range 0.0 .. 1.0.

media . muted [ = value ]

음소거 상태일 경우 volume 속성에 무관하게 true를 반환하며, 그렇지 않다면 false를 반환합니다.

Returns true if audio is muted, overriding the volume attribute, and false if the volume attribute is being honored.

음소거 상태를 설정할 수 있습니다.

Can be set, to change whether the audio is muted or not.

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 must 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 attribute must be set to the new value and the playback volume must be correspondingly adjusted as soon as possible after setting the attribute, 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. If the new value is outside the range 0.0 to 1.0 inclusive, then, on setting, an INDEX_SIZE_ERR exception must be raised instead.

The muted attribute must return true if the audio channels are muted and false otherwise. Initially, the audio channels 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, the attribute must be set to the new value; if the new value is true, audio playback for this media resource must then be muted, and if false, audio playback must then be enabled.

Whenever either the muted or volume attributes are changed, the user agent must queue a task to fire a simple event named volumechange at the media element.

video 요소의 audio 속성은 미디어 자원의 오디오 채널의 기본 상태를 제어하며, 사용자 환경 설정을 덮어 쓸 가능성이 있습니다.

The audio attribute on the video element controls the default state of the audio channel of the media resource, potentially overriding user preferences.

audio 속성의 값은 공백문자로 구분되고 순서 없이 유일한 토큰의 목록이어야 하며 아스키, 대소문자 구분없이 비교합니다. 토큰은 다음의 목록에 있는 것이어야 합니다(현재는 단 한가지 토큰만이 정의되어 있습니다)

The audio attribute, if specified, must have a value that is an unordered set of unique space-separated tokens, which are ASCII case-insensitive. The tokens must be from the following list (currently, only one allowed token is defined):

muted

사용자 환경 설정이 있더라도 그것을 덮어쓰며 항상 비디오의 기본값을 음소거 상태로 만듭니다.

Causes the user agent to override the user's preferences, if any, and always default the video to muted.

명세의 이후 버전에서는 새로운 값들을 도입할 것입니다. 예를 들어 볼륨 기본값, 혹은 오디오 트랙의 기본값을 선택하는 것 등입니다.

A future version of this specification will probably introduce new values here, e.g. to control the default volume, or to select a default audio track.

When a video element is created, if it has an audio attribute specified, the user agent must split the attribute's value on spaces; if any of the tokens are an ASCII case-insensitive match for the string muted, the user agent must then set the muted attribute to true, overriding any user preference.

이 속성은 동적인 효과를 갖지 않습니다 (단순히 요소의 기본값만을 제어합니다).

This attribute has no dynamic effect (it only controls the default state of the element).

이 광고 비디오는 자동으로 재생되지만 사용자를 짜증나지 않게 하기 위해 음소거 상태로 재생되며 사용자가 소리를 켤 수 있습니다.

This video (an advertisment) autoplays, but to avoid annoying users, it does so without sound, and allows the user to turn the sound on.

<video src="adverts.cgi?kind=video" controls autoplay loop audio=muted></video>
4.8.10.12 시간 범위

TimeRanges 인터페이스를 구현하는 객체는 시간 범위의 목록을 나타냅니다.

Objects implementing the TimeRanges interface represent a list of ranges (periods) of time.

interface TimeRanges {
  readonly attribute unsigned long length;
  double start(in unsigned long index);
  double end(in unsigned long index);
};
media . length

객체에 들어있는 범위의 갯수를 반환합니다.

Returns the number of ranges in the object.

time = media . start(index)

주어진 index에 해당하는 범위의 시작 시간을 반환합니다.

Returns the time for the start of the range with the given index.

index가 범위를 벗어났을 경우 INDEX_SIZE_ERR 에러를 반환합니다.

Throws an INDEX_SIZE_ERR if the index is out of range.

time = media . end(index)

주어진 index에 해당하는 범위의 종료 시간을 반환합니다.

Returns the time for the end of the range with the given index.

index가 범위를 벗어났을 경우 INDEX_SIZE_ERR 에러를 반환합니다.

Throws an INDEX_SIZE_ERR if the index is out of range.

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 raise INDEX_SIZE_ERR 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).

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.8.10.13 이벤트 요약

This section is non-normative.

미디어 요소에서 아래에 설명되는 처리 모델의 일부로 다음의 이벤트들이 발생합니다.

The following events fire on media elements as part of the processing model described above:

이벤트 이름

Event name

인터페이스

Interface

발생하는 상황

Dispatched when...

선 조건

Preconditions

loadstart Event

사용자 에이전트가 미디어 데이터를 검색하기 시작합니다. 이러한 검색은 자원 선택 알고리즘의 일부분입니다.

The user agent begins looking for media data, as part of the resource selection algorithm.

networkState equals NETWORK_LOADING
progress Event

사용자 에이전트가 미디어 데이터를 가져오고 있습니다.

The user agent is fetching media data.

networkState equals NETWORK_LOADING
suspend Event

사용자 에이전트는 현재 미디어 데이터를 가져오고 있지 않으며, 이러한 것은 의도된 것입니다. 아직 미디어 자원 전체를 내려받지 않았습니다.

The user agent is intentionally not currently fetching media data, but does not have the entire media resource downloaded.

networkState equals NETWORK_IDLE
abort Event

사용자 에이전트가 미디어 데이터를 완전히 다운로드하기 전에 중지했지만 이것이 에러 때문은 아닙니다.

The user agent stops fetching the media data before it is completely downloaded, but not due to an error.

error is an object with the code MEDIA_ERR_ABORTED. networkState equals either NETWORK_EMPTY or NETWORK_IDLE, depending on when the download was aborted.
error Event

미디어 데이터를 가져오는 과정에서 에러가 발생했습니다.

An error occurs while fetching the media data.

error is an object with the code MEDIA_ERR_NETWORK or higher. networkState equals either NETWORK_EMPTY or NETWORK_IDLE, depending on when the download was aborted.
emptied Event

이전에 NETWORK_EMPTY 상태가 아니었던 미디어 요소가 그러한 상태로 지금 막 변경되었습니다.(사용자에게 보고를 준비중인, 로드 중의 심각한 에러 때문이었을수도 있고, 자원 선택 알고리즘이 이미 실행중인 상태에서 load() 메서드를 호출했기 때문일수도 있습니다.)

A media element whose networkState was previously not in the NETWORK_EMPTY state has just switched to that state (either because of a fatal error during load that's about to be reported, or because the load() method was invoked while the resource selection algorithm was already running).

networkState is NETWORK_EMPTY; all the IDL attributes are in their initial states.
stalled Event

사용자 에이전트가 미디어 데이터를 가져오려고 하고 있지만, 데이터가 예기치못하게 단절되었습니다.

The user agent is trying to fetch media data, but data is unexpectedly not forthcoming.

networkState is NETWORK_LOADING.
play Event

재생이 시작되었습니다. play() 메서드가 반환된 뒤, 혹은 autoplay 속성으로 재생을 시작한 이후입니다.

Playback has begun. Fired after the play() method has returned, or when the autoplay attribute has caused playback to begin.

paused is newly false.
pause Event

재생이 일시 정지되었습니다. pause() 메서드가 반환된 뒤에 일어납니다.

Playback has been paused. Fired after the pause() method has returned.

paused is newly true.
loadedmetadata Event

사용자 에이전트가 이제 막 미디어 자원의 길이와 크기를 판단하였고 텍스트 트랙이 준비되었습니다.

The user agent has just determined the duration and dimensions of the media resource and the text tracks are ready.

readyState is newly equal to HAVE_METADATA or greater for the first time.
loadeddata Event

사용자 에이전트는 현재의 재생 위치에 대해서 미디어 데이터를 처음으로 렌더링 할 수 있습니다.

The user agent can render the media data at the current playback position for the first time.

readyState newly increased to HAVE_CURRENT_DATA or greater for the first time.
waiting Event

다음 프레임을 사용할 수 없어서 재생이 중단되었습니다. 하지만 사용자 에이전트는 그 프레임이 곧 사용 가능해지리라 예상하고 있습니다.

Playback has stopped because the next frame is not available, but the user agent expects that frame to become available in due course.

readyState is newly equal to or less than HAVE_CURRENT_DATA, and paused is false. Either seeking is true, or the current playback position is not contained in any of the ranges in buffered. It is possible for playback to stop for two other reasons without paused being false, but those two reasons do not fire this event: maybe playback ended, or playback stopped due to errors.
playing Event

재생이 시작되었습니다.

Playback has started.

readyState is newly equal to or greater than HAVE_FUTURE_DATA, paused is false, seeking is false, or the current playback position is contained in one of the ranges in buffered.
canplay Event

사용자 에이전트는 미디어 데이터의 재생을 다시 시작할 수 있지만, 지금 다시 시작할 경우 현재의 재생 속도로 진행한다면 버퍼링을 위해 멈추는 일 없이 끝까지 재생하는 것은 불가능할 것이라 예측하고 있습니다.

The user agent can resume playback of the media data, but estimates that if playback were to be started now, the media resource could not be rendered at the current playback rate up to its end without having to stop for further buffering of content.

readyState newly increased to HAVE_FUTURE_DATA or greater.
canplaythrough Event

재생을 지금 시작할 경우, 현재의 재생 속도로 진행한다면 버퍼링을 위해 멈추는 일 없이 끝까지 진행할 수 있을 것이라 예측하고 있습니다.

The user agent estimates that if playback were to be started now, the media resource could be rendered at the current playback rate all the way to its end without having to stop for further buffering.

readyState is newly equal to HAVE_ENOUGH_DATA.
seeking Event

IDL 속성 seeking이 true로 바뀌었고, 탐색 작업에 시간이 걸려서 사용자 에이전트가 이 이벤트를 발생시킬 시간이 있었습니다.

The seeking IDL attribute changed to true and the seek operation is taking long enough that the user agent has time to fire the event.

seeked Event

IDL 속성 seeking이 false로 바뀌었습니다.

The seeking IDL attribute changed to false.

timeupdate Event

현재의 재생 위치가 바뀌었습니다. 일반적인 재생 때문이었을수도 있고, 특히 흥미로운 경우 - 예를 들어 비연속성 - 때문이었을수도 있습니다(...?)

The current playback position changed as part of normal playback or in an especially interesting way, for example discontinuously.

ended Event

미디어 자원의 끝에 도달하였으므로 재생이 정지되었습니다.

Playback has stopped because the end of the media resource was reached.

currentTime equals the end of the media resource; ended is true.
ratechange Event

defaultPlaybackRate 또는 playbackRate 속성이 지금 막 업데이트되었습니다.

Either the defaultPlaybackRate or the playbackRate attribute has just been updated.

durationchange Event

duration 속성이 지금 막 업데이트되었습니다.

The duration attribute has just been updated.

volumechange Event

volume 또는 muted 속성이 변경되었습니다. 관련된 속성의 설정자가 반환된 뒤에 발생합니다.

Either the volume attribute or the muted attribute has changed. Fired after the relevant attribute's setter has returned.

4.8.10.14 보안과 개인 정보에 관한 고려

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. This version of the API does not expose such information. Future extensions to this API will likely reuse a mechanism such as CORS to check that the embedded content's site has opted in to exposing such information. [CORS]

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 confidentiality breach.

4.8.10.15 미디어 요소 사용의 모범 사례(저자)

This section is non-normative.

셋탑 박스나 휴대폰 같은 작은 장치에서 오디오/비디오 자원을 재생하려고 하면, 종종 그러한 장치의 하드웨어 자원에 의해 제약을 받습니다. 예를 들어 장치에서 비디오의 동시 재생을 3개까지만 지원할수도 있습니다. 따라서 미디어 요소가 재생을 완료하면 그 요소에서 사용하던 자원을 반환하도록 하는 것이 좋습니다. 두가지 방법으로 이렇게 할 수 있습니다: 1) 요소에 대한 모든 참조를 아주 주의깊게 제거하여 메모리 반환이 일어나도록 합니다. 2) 더 좋은 방법은: 요소의 src 속성과 모든 source 자손 요소를 없앤 후 요소의 load() 메서드를 호출하는 것입니다.

Playing audio and video resources on small devices such as set-top boxes or mobile phones is often constrained by limited hardware resources in the device. For example, a device might only support three simultaneous videos. For this reason, it is a good practice to release resources held by media elements when they are done playing, either by being very careful about removing all references to the element and allowing it to be garbage collected, or, even better, by removing the element's src attribute and any source element descendants, and invoking the element's load() method.

4.8.10.16 미디어 요소 구현의 모범 사례(제작자)

This section is non-normative.

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 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.)

아래 정의 목록에서 컨테이너container란 비디오/오디오 데이터를 묶어서 함께 전송하는 것입니다. 사용한 코덱에 대한 정보도 포함되어 있습니다. 돌아가기

NaN은 숫자를 요청했지만 문자를 받은 경우, Infinity는 무한대를 나타내는 자바스크립트 표현입니다. 돌아가기

스크린 리더 사용자의 입장에서는 페이지의 텍스트를 읽고 있는데 난데없이 음악이나 대사 따위가 페이지 텍스트에 오버랩된다면 상당히 불유쾌할 것입니다. Web Contents Accessibility Guide 2.0에서 이러한 사항을 몇개의 장에 걸쳐서 자세하게 설명하고 있습니다. 돌아가기

불리언boolean이란 참/거짓 두가지 값만을 갖는 변수 혹은 상태입니다. 돌아가기