HTML <track>タグ
例
2つの言語の字幕トラックを含むビデオ:
<video width="320" height="240" controls>
<source src="forrest_gump.mp4" type="video/mp4">
<source src="forrest_gump.ogg" type="video/ogg">
<track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English">
<track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video>
定義と使用法
タグは、 <audio>または<video>
要素の<track>
テキストトラックを指定します
。
この要素は、メディアの再生時に表示される字幕、キャプションファイル、またはテキストを含むその他のファイルを指定するために使用されます。
トラックはWebVTT形式(.vttファイル)でフォーマットされています。
ブラウザのサポート
表の数字は、要素を完全にサポートする最初のブラウザバージョンを示しています。
Element | |||||
---|---|---|---|---|---|
<track> | 23.0 | 10.0 | 31.0 | 6.0 | 12.1 |
オプションの属性
Attribute | Value | Description |
---|---|---|
default | default | Specifies that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate |
kind | captions chapters descriptions metadata subtitles |
Specifies the kind of text track |
label | text | Specifies the title of the text track |
src | URL | Required. Specifies the URL of the track file |
srclang | language_code | Specifies the language of the track text data (required if kind="subtitles") |
グローバル属性
この<track>
タグは、HTMLのグローバル属性もサポートしています。
イベント属性
この<track>
タグは、HTMLのイベント属性もサポートしています。
関連ページ
HTMLチュートリアル:HTMLビデオ
HTMLチュートリアル:HTMLオーディオ
HTML DOMリファレンス:トラックオブジェクト
デフォルトのCSS設定
なし。