Skip to content

Commit 4aaacb7

Browse files
authored
Treat text track chapters as metadata
Fixes whatwg#2507.
1 parent b143dbc commit 4aaacb7

File tree

1 file changed

+20
-170
lines changed

1 file changed

+20
-170
lines changed

source

Lines changed: 20 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,15 +3651,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
36513651

36523652
<dd>
36533653

3654-
<p>Implementations may support WebVTT as a text track format for subtitles, captions, chapter
3655-
titles, metadata, etc, for media resources. <ref spec=WEBVTT></p>
3654+
<p>Implementations may support WebVTT as a text track format for subtitles, captions, metadata,
3655+
etc., for media resources. <ref spec=WEBVTT></p>
36563656

36573657
<p>The following terms, used in this specification, are defined in the WebVTT specification:</p>
36583658

36593659
<ul class="brief">
36603660
<li><dfn data-x-href="https://w3c.github.io/webvtt/#webvtt-file">WebVTT file</dfn></li>
36613661
<li><dfn data-x-href="https://w3c.github.io/webvtt/#webvtt-file-using-cue-text">WebVTT file using cue text</dfn></li>
3662-
<li><dfn data-x-href="https://w3c.github.io/webvtt/#webvtt-file-using-chapter-title-text">WebVTT file using chapter title text</dfn></li>
36633662
<li><dfn data-x-href="https://w3c.github.io/webvtt/#webvtt-file-using-only-nested-cues">WebVTT file using only nested cues</dfn></li>
36643663
<li><dfn data-x-href="https://w3c.github.io/webvtt/#webvtt-parser">WebVTT parser</dfn></li>
36653664
<li>The <dfn data-x-href="https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks">rules for updating the display of WebVTT text tracks</dfn></li>
@@ -31801,16 +31800,13 @@ interface <dfn>HTMLTrackElement</dfn> : <span>HTMLElement</span> {
3180131800
Synthesized as audio.
3180231801
<tr>
3180331802
<td><dfn><code data-x="attr-track-kind-keyword-chapters">chapters</code></dfn>
31804-
<td><dfn data-x="attr-track-kind-chapters">Chapters</dfn>
31805-
<td>
31806-
Chapter titles, intended to be used for navigating the <span>media resource</span>.
31807-
Displayed as an interactive (potentially nested) list in the user agent's interface.
31803+
<td><dfn data-x="attr-track-kind-chapters">Chapters metadata</dfn>
31804+
<td rowspan="2">
31805+
Tracks intended for use from script.
31806+
Not displayed by the user agent.
3180831807
<tr>
3180931808
<td><dfn><code data-x="attr-track-kind-keyword-metadata">metadata</code></dfn>
3181031809
<td><dfn data-x="attr-track-kind-metadata">Metadata</dfn>
31811-
<td>
31812-
Tracks intended for use from script.
31813-
Not displayed by the user agent.
3181431810
</table>
3181531811

3181631812
<p>The attribute may be omitted. The <i data-x="missing value default">missing value default</i>
@@ -31834,15 +31830,10 @@ interface <dfn>HTMLTrackElement</dfn> : <span>HTMLElement</span> {
3183431830

3183531831
<p>If the element's <span>track URL</span> identifies a WebVTT resource, and the element's <code
3183631832
data-x="attr-track-kind">kind</code> attribute is not in the <span
31833+
data-x="attr-track-kind-chapters">chapters metadata</span> or <span
3183731834
data-x="attr-track-kind-metadata">metadata</span> state, then the WebVTT file must be a
3183831835
<span>WebVTT file using cue text</span>. <ref spec=WEBVTT></p>
3183931836

31840-
<p>Furthermore, if the element's <span>track URL</span> identifies a WebVTT resource, and the
31841-
element's <code data-x="attr-track-kind">kind</code> attribute is in the <span
31842-
data-x="attr-track-kind-chapters">chapters</span> state, then the WebVTT file must be both a
31843-
<span>WebVTT file using chapter title text</span> and a <span>WebVTT file using only nested
31844-
cues</span>. <ref spec=WEBVTT></p>
31845-
3184631837
<p>The <dfn><code data-x="attr-track-srclang">srclang</code></dfn> attribute gives the language of
3184731838
the text track data. The value must be a valid BCP 47 language tag. This attribute must be present
3184831839
if the element's <code data-x="attr-track-kind">kind</code> attribute is in the <span
@@ -31895,7 +31886,7 @@ interface <dfn>HTMLTrackElement</dfn> : <span>HTMLElement</span> {
3189531886

3189631887
<p>Each <span>media element</span> must have no more than one <code>track</code> element child
3189731888
whose <code data-x="attr-track-kind">kind</code> attribute is in the <span
31898-
data-x="attr-track-kind-chapters">chapters</span> state and whose <code
31889+
data-x="attr-track-kind-chapters">chapters metadata</span> state and whose <code
3189931890
data-x="attr-track-default">default</code> attribute is specified.</p>
3190031891

3190131892
<p class="note">There is no limit on the number of <code>track</code> elements whose <code
@@ -36059,12 +36050,6 @@ interface <dfn>VideoTrack</dfn> {
3605936050
writing direction</span> and so forth. <ref spec=WEBVTT></p>
3606036051
</dd>
3606136052

36062-
<dt><dfn data-x="text track rules for extracting the chapter title">Rules for extracting the chapter title</dfn>
36063-
<dd>
36064-
<p>An algorithm which, when applied to the cue, returns a string that can be used in user
36065-
interfaces that use the cue as a chapter title.</p>
36066-
</dd>
36067-
3606836053
</dl>
3606936054

3607036055
<p class="note">The <span>text track cue start time</span> and <span>text track cue end
@@ -36172,6 +36157,7 @@ interface <dfn>VideoTrack</dfn> {
3617236157
<li>
3617336158

3617436159
<p>If the new <span>text track</span>'s <span data-x="text track kind">kind</span> is <code
36160+
data-x="dom-TextTrack-kind-chapters">chapters</code> or <code
3617536161
data-x="dom-TextTrack-kind-metadata">metadata</code>, then set the <span>text track in-band
3617636162
metadata track dispatch type</span> as follows, based on the type of the <span>media
3617736163
resource</span>:</p>
@@ -36309,7 +36295,7 @@ interface <dfn>VideoTrack</dfn> {
3630936295
<td><span data-x="attr-track-kind-descriptions">Descriptions</span>
3631036296
<td><code data-x="dom-TextTrack-kind-descriptions">descriptions</code>
3631136297
<tr>
36312-
<td><span data-x="attr-track-kind-chapters">Chapters</span>
36298+
<td><span data-x="attr-track-kind-chapters">Chapters metadata</span>
3631336299
<td><code data-x="dom-TextTrack-kind-chapters">chapters</code>
3631436300
<tr>
3631536301
<td><span data-x="attr-track-kind-metadata">Metadata</span>
@@ -36385,11 +36371,9 @@ interface <dfn>VideoTrack</dfn> {
3638536371
<li><p><span>Perform automatic text track selection</span> for <code
3638636372
data-x="dom-TextTrack-kind-descriptions">descriptions</code>.</p></li>
3638736373

36388-
<li><p><span>Perform automatic text track selection</span> for <code
36389-
data-x="dom-TextTrack-kind-chapters">chapters</code>.</p></li>
36390-
3639136374
<li><p>If there are any <span data-x="text track">text tracks</span> in the <span>media
3639236375
element</span>'s <span>list of text tracks</span> whose <span>text track kind</span> is <code
36376+
data-x="dom-TextTrack-kind-metadata">chapters</code> or <code
3639336377
data-x="dom-TextTrack-kind-metadata">metadata</code> that correspond to <code>track</code>
3639436378
elements with a <code data-x="attr-track-default">default</code> attribute set whose <span>text
3639536379
track mode</span> is set to <span data-x="text track disabled">disabled</span>, then set the
@@ -37227,132 +37211,6 @@ interface <dfn>TextTrackCue</dfn> : <span>EventTarget</span> {
3722737211
On setting, the <span>text track cue pause-on-exit flag</span> must be set if the new value is
3722837212
true, and must be unset otherwise.</p>
3722937213

37230-
</div>
37231-
37232-
37233-
<h6>Text tracks describing chapters</h6>
37234-
37235-
<p>Chapters are segments of a <span>media resource</span> with a given title. Chapters can be
37236-
nested, in the same way that sections in a document outline can have subsections.</p>
37237-
37238-
<p>Each <span>text track cue</span> in a <span>text track</span> being used for describing
37239-
chapters has three key features: the <span>text track cue start time</span>, giving the start time
37240-
of the chapter, the <span>text track cue end time</span>, giving the end time of the chapter, and
37241-
the <span>text track rules for extracting the chapter title</span>.</p>
37242-
37243-
<div w-nodev>
37244-
37245-
<p>The <dfn>rules for constructing the chapter tree from a text track</dfn> are as follows. They
37246-
produce a potentially nested list of chapters, each of which have a start time, end time, title,
37247-
and a list of nested chapters. This algorithm discards cues that do not correctly nest within each
37248-
other, or that are out of order.</p>
37249-
37250-
<ol>
37251-
37252-
<li><p>Let <var>list</var> be a copy of the <span data-x="text track list of cues">list
37253-
of cues</span> of the <span>text track</span> being processed.</p></li>
37254-
37255-
<li><p>Remove from <var>list</var> any <span>text track cue</span> whose <span>text
37256-
track cue end time</span> is before its <span>text track cue start time</span>.</p></li>
37257-
37258-
<li><p>Let <var>output</var> be an empty list of chapters, where a chapter is a record
37259-
consisting of a start time, an end time, a title, and a (potentially empty) list of nested
37260-
chapters. For the purpose of this algorithm, each chapter also has a parent chapter.</p></li>
37261-
37262-
<li><p>Let <var>current chapter</var> be a stand-in chapter whose start time is negative
37263-
infinity, whose end time is positive infinity, and whose list of nested chapters is <var>output</var>. (This is just used to make the algorithm easier to describe.)</p></li>
37264-
37265-
<!-- while not empty... -->
37266-
<li><p><i>Loop</i>: If <var>list</var> is empty, jump to the step labeled
37267-
<i>end</i>.</p></li>
37268-
37269-
<!-- do... -->
37270-
<li><p>Let <var>current cue</var> be the first cue in <var>list</var>, and then
37271-
remove it from <var>list</var>.</p></li>
37272-
37273-
<li><p>If <var>current cue</var>'s <span>text track cue start time</span> is less than
37274-
the start time of <var>current chapter</var>, then return to the step labeled
37275-
<i>loop</i>.</p> <!-- out of order chapter -->
37276-
37277-
<li><p>While <var>current cue</var>'s <span>text track cue start time</span> is greater
37278-
than or equal to <var>current chapter</var>'s end time, let <var>current
37279-
chapter</var> be <var>current chapter</var>'s parent chapter.</p></li>
37280-
37281-
<li><p>If <var>current cue</var>'s <span>text track cue end time</span> is greater than
37282-
the end time of <var>current chapter</var>, then return to the step labeled
37283-
<i>loop</i>.</p> <!-- misnested chapter -->
37284-
37285-
<li>
37286-
37287-
<p>Create a new chapter <var>new chapter</var>, whose start time is <var>current cue</var>'s <span>text track cue start time</span>, whose end time is <var>current cue</var>'s <span>text track cue end time</span>, whose title is the result of running <var>current cue</var>'s <span>text track rules for extracting the chapter title</span>, and whose list of nested chapters is
37288-
empty.</p>
37289-
37290-
</li>
37291-
37292-
<li><p>Append <var>new chapter</var> to <var>current chapter</var>'s list of
37293-
nested chapters, and let <var>current chapter</var> be <var>new chapter</var>'s
37294-
parent.</p></li>
37295-
37296-
<li><p>Let <var>current chapter</var> be <var>new chapter</var>.</p></li>
37297-
37298-
<li><p>Return to the step labeled <i>loop</i>.</p></li>
37299-
<!-- ...end while -->
37300-
37301-
<li><p><i>End</i>: Return <var>output</var>.</p></li>
37302-
37303-
</ol>
37304-
37305-
</div>
37306-
37307-
<div class="example">
37308-
37309-
<p>The following snippet of a <span>WebVTT file</span> shows how nested chapters can be marked
37310-
up. The file describes three 50-minute chapters, "Astrophysics", "Computational Physics", and
37311-
"General Relativity". The first has three subchapters, the second has four, and the third has
37312-
two. <ref spec=WEBVTT></p>
37313-
37314-
<pre>WEBVTT
37315-
37316-
00:00:00.000 --> 00:50:00.000
37317-
Astrophysics
37318-
37319-
00:00:00.000 --> 00:10:00.000
37320-
Introduction to Astrophysics
37321-
37322-
00:10:00.000 --> 00:45:00.000
37323-
The Solar System
37324-
37325-
00:00:00.000 --> 00:10:00.000
37326-
Coursework Description
37327-
37328-
00:50:00.000 --> 01:40:00.000
37329-
Computational Physics
37330-
37331-
00:50:00.000 --> 00:55:00.000
37332-
Introduction to Programming
37333-
37334-
00:55:00.000 --> 01:30:00.000
37335-
Data Structures
37336-
37337-
01:30:00.000 --> 01:35:00.000
37338-
Answers to Last Exam
37339-
37340-
01:35:00.000 --> 01:40:00.000
37341-
Coursework Description
37342-
37343-
01:40:00.000 --> 02:30:00.000
37344-
General Relativity
37345-
37346-
01:40:00.000 --> 02:00:00.000
37347-
Tensor Algebra
37348-
37349-
02:00:00.000 --> 02:30:00.000
37350-
The General Relativistic Field Equations</pre>
37351-
37352-
</div>
37353-
37354-
37355-
<div w-nodev>
3735637214

3735737215
<h6 id="cue-events">Event handlers for objects of the text track APIs</h6>
3735837216

@@ -37526,14 +37384,6 @@ red:89
3752637384
the <i>approximate-for-speed</i> flag when seeking in response to the user manipulating an
3752737385
approximate position interface such as a seek bar.</p>
3752837386

37529-
<p>For the purposes of listing chapters in the <span>media resource</span>, only <span data-x="text
37530-
track">text tracks</span> in the <span>media element</span>'s <span>list of text tracks</span>
37531-
that are <span data-x="text track showing">showing</span> and whose <span>text track kind</span> is
37532-
<code data-x="dom-TextTrack-kind-chapters">chapters</code> should be used. Such tracks must be
37533-
interpreted according to the <span>rules for constructing the chapter tree from a text
37534-
track</span>. When seeking in response to a user manipulating a chapter selection interface, user
37535-
agents should not use the <i>approximate-for-speed</i> flag.</p>
37536-
3753737387
<p>The <dfn><code data-x="dom-media-controls">controls</code></dfn> IDL attribute must
3753837388
<span>reflect</span> the content attribute of the same name.</p>
3753937389

@@ -38294,10 +38144,9 @@ dictionary <dfn>TrackEventInit</dfn> : <span>EventInit</span> {
3829438144
has been deemed acceptable.</p>
3829538145

3829638146
<p>However, significantly more sensitive information could be obtained if the user agent further
38297-
exposes metadata within the content such as subtitles or chapter titles. Such information is
38298-
therefore only exposed if the video resource uses CORS. The <code
38299-
data-x="attr-media-crossorigin">crossorigin</code> attribute allows authors to enable CORS. <ref
38300-
spec=FETCH></p>
38147+
exposes metadata within the content, such as subtitles. That information is therefore only exposed
38148+
if the video resource uses CORS. The <code data-x="attr-media-crossorigin">crossorigin</code>
38149+
attribute allows authors to enable CORS. <ref spec=FETCH></p>
3830138150

3830238151
<p class="example">Without this restriction, an attacker could trick a user running within a
3830338152
corporate network into visiting a site that attempts to load a video from a previously leaked
@@ -117501,11 +117350,11 @@ interface <dfn>External</dfn> {
117501117350
<th> <code data-x="">kind</code>
117502117351
<td> <code data-x="attr-track-kind">track</code>
117503117352
<td> The type of text track
117504-
<td> "<code data-x="attr-track-kind-subtitles">subtitles</code>";
117505-
"<code data-x="attr-track-kind-captions">captions</code>";
117506-
"<code data-x="attr-track-kind-descriptions">descriptions</code>";
117507-
"<code data-x="attr-track-kind-chapters">chapters</code>";
117508-
"<code data-x="attr-track-kind-metadata">metadata</code>"
117353+
<td> "<code data-x="attr-track-kind-keyword-subtitles">subtitles</code>";
117354+
"<code data-x="attr-track-kind-keyword-captions">captions</code>";
117355+
"<code data-x="attr-track-kind-keyword-descriptions">descriptions</code>";
117356+
"<code data-x="attr-track-kind-keyword-chapters">chapters</code>";
117357+
"<code data-x="attr-track-kind-keyword-metadata">metadata</code>"
117509117358
<tr>
117510117359
<th> <code data-x="">label</code>
117511117360
<td> <code data-x="attr-optgroup-label">optgroup</code>;
@@ -120295,6 +120144,7 @@ INSERT INTERFACES HERE
120295120144
Gareth Rees,
120296120145
Garrett Smith,
120297120146
Gary Kacmarcik,
120147+
Gary Katsevman,
120298120148
Geoff Richards,
120299120149
Geoffrey Garen,
120300120150
Geoffrey Sneddon,

0 commit comments

Comments
 (0)