Skip to content

Commit 8ebd581

Browse files
Zhiqiang Zhangfoolip
authored andcommitted
Allow delaying autoplay until video elements become visible
Starting autoplay when media elements loaded is too agressive. Added supplementary saying that the user agent may delay autoplay until video elements become visible. PR: #1409
1 parent c8afae0 commit 8ebd581

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

source

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29967,6 +29967,10 @@ interface <dfn>HTMLVideoElement</dfn> : <span>HTMLMediaElement</span> {
2996729967
<p>The <span>default object size</span> is a width of 300 <span data-x="'px'">CSS pixels</span>
2996829968
and a height of 150 <span data-x="'px'">CSS pixels</span>. <ref spec=CSSIMAGES></p>
2996929969

29970+
<p>A <code>video</code> element is said to <dfn>intersect the viewport</dfn> when it is
29971+
<span>being rendered</span> and its associated CSS layout box intersects the
29972+
<span>viewport</span>.</p>
29973+
2997029974
<hr>
2997129975

2997229976
<p>User agents should provide controls to enable or disable the display of closed captions, audio
@@ -32598,12 +32602,20 @@ interface <dfn>HTMLMediaElement</dfn> : <span>HTMLElement</span> {
3259832602
data-x="dom-media-paused">paused</code> attribute is false, <span>notify about playing</span>
3259932603
for the element.</p>
3260032604

32601-
<p>If the <span>autoplaying flag</span> is true, and the <code
32602-
data-x="dom-media-paused">paused</code> attribute is true, and the <span>media element</span>
32603-
has an <code data-x="attr-media-autoplay">autoplay</code> attribute specified, and the
32604-
<span>media element</span>'s <span>node document</span>'s <span>active sandboxing flag set</span>
32605-
does not have the <span>sandboxed automatic features browsing context flag</span> set, then
32606-
the user agent may also run the following substeps:</p>
32605+
<p>The user agent must <span>queue a task</span> to <span>fire a simple event</span> named
32606+
<code data-x="event-media-canplaythrough">canplaythrough</code> at the element.</p>
32607+
32608+
<p>If the element is not <span>eligible for autoplay</span>, then the user agent must abort
32609+
these substeps.</p>
32610+
32611+
<p>The user agent may run the following substeps immediately. Alternatively, if the element is
32612+
a <code>video</code> element, the user agent may wait until the element <span
32613+
data-x="intersect the viewport">intersects the viewport</span> and, if the element is still
32614+
<span>eligible for autoplay</span>, run the following substeps:</p>
32615+
32616+
<p class="note">This specification doesn't define the precise timing for when the intersection
32617+
is tested, but it is recommended that the timing match that of the Intersection Observer
32618+
API. <ref spec=INTERSECTIONOBSERVER></p>
3260732619

3260832620
<ol>
3260932621

@@ -32626,9 +32638,6 @@ interface <dfn>HTMLMediaElement</dfn> : <span>HTMLElement</span> {
3262632638
data-x="attr-media-autoplay">autoplay</code> attribute rather than using script to force the
3262732639
video to play, so as to allow the user to override the behaviour if so desired.</p>
3262832640

32629-
<p>In any case, the user agent must finally <span>queue a task</span> to <span>fire a simple
32630-
event</span> named <code data-x="event-media-canplaythrough">canplaythrough</code> at the element.</p>
32631-
3263232641
</dd>
3263332642

3263432643
</dl>
@@ -32772,6 +32781,12 @@ interface <dfn>HTMLMediaElement</dfn> : <span>HTMLElement</span> {
3277232781
data-x="dom-media-readyState">readyState</code> attribute changing to a value lower than <code
3277332782
data-x="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code>.</p>
3277432783

32784+
<p>A <span>media element</span> is said to be <dfn>eligible for autoplay</dfn> when its
32785+
<span>autoplaying flag</span> is true, its <code data-x="dom-media-paused">paused</code> attribute
32786+
is true, the element has an <code data-x="attr-media-autoplay">autoplay</code> attribute
32787+
specified, and the element's <span>node document</span>'s <span>active sandboxing flag set</span>
32788+
does not have the <span>sandboxed automatic features browsing context flag</span> set.</p>
32789+
3277532790
<p>A <span>media element</span> is said to have <dfn>ended playback</dfn> when:</p>
3277632791

3277732792
<ul>
@@ -119776,6 +119791,7 @@ INSERT INTERFACES HERE
119776119791
Yonathan Randolph,
119777119792
Yuzo Fujishima,
119778119793
Zhenbin Xu,
119794+
&#24352;&#26234;&#24378; (Zhiqiang Zhang),
119779119795
Zoltan Herczeg,
119780119796
and
119781119797
&Oslash;istein E. Andersen,

0 commit comments

Comments
 (0)