Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow delaying autoplay until video elements become visible #1409

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -29967,6 +29967,10 @@ interface <dfn>HTMLVideoElement</dfn> : <span>HTMLMediaElement</span> {
<p>The <span>default object size</span> is a width of 300 <span data-x="'px'">CSS pixels</span>
and a height of 150 <span data-x="'px'">CSS pixels</span>. <ref spec=CSSIMAGES></p>

<p>A <code>video</code> element is said to <dfn>intersect the viewport</dfn> when it is
<span>being rendered</span> and its associated CSS layout box intersects the
<span>viewport</span>.</p>

<hr>

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

<p>If the <span>autoplaying flag</span> is true, and the <code
data-x="dom-media-paused">paused</code> attribute is true, and the <span>media element</span>
has an <code data-x="attr-media-autoplay">autoplay</code> attribute specified, and the
<span>media element</span>'s <span>node document</span>'s <span>active sandboxing flag set</span>
does not have the <span>sandboxed automatic features browsing context flag</span> set, then
the user agent may also run the following substeps:</p>
<p>The user agent must <span>queue a task</span> to <span>fire a simple event</span> named
<code data-x="event-media-canplaythrough">canplaythrough</code> at the element.</p>

<p>If the element is not <span>eligible for autoplay</span>, then the user agent must abort
these substeps.</p>

<p>The user agent may run the following substeps immediately. Alternatively, if the element is
a <code>video</code> element, the user agent may wait until the element <span
data-x="intersect the viewport">intersects the viewport</span> and, if the element is still
<span>eligible for autoplay</span>, run the following substeps:</p>

<p class="note">This specification doesn't define the precise timing for when the intersection
is tested, but it is recommended that the timing match that of the Intersection Observer
API. <ref spec=INTERSECTIONOBSERVER></p>

<ol>

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

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

</dd>

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

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

<p>A <span>media element</span> is said to have <dfn>ended playback</dfn> when:</p>

<ul>
Expand Down Expand Up @@ -119776,6 +119791,7 @@ INSERT INTERFACES HERE
Yonathan Randolph,
Yuzo Fujishima,
Zhenbin Xu,
&#24352;&#26234;&#24378; (Zhiqiang Zhang),
Zoltan Herczeg,
and
&Oslash;istein E. Andersen,
Expand Down