Skip to content

Conversation

@xxyzzzq
Copy link
Contributor

@xxyzzzq xxyzzzq commented Feb 6, 2017

  • Allow the user agent to interrupt an autoplaying video when it becomes invisible.
  • Renamed the confusing name "autoplaying flag" to "autoplay on demand flag".

@xxyzzzq
Copy link
Contributor Author

xxyzzzq commented Feb 6, 2017

@foolip @mounirlamouri PTAL

@mounirlamouri
Copy link
Member

This is also changing the behavior when a video starts autoplaying to no longer set the flag to false, right?

@zcorpan
Copy link
Member

zcorpan commented Feb 6, 2017

  • Is this web compatible?
  • Would it not be nice to have the ability to "auto pause" without autoplay?

@zcorpan zcorpan added topic: media addition/proposal New features or enhancements labels Feb 6, 2017
@xxyzzzq xxyzzzq force-pushed the autoplaying_flag_fix branch from 2e0317c to 726b535 Compare February 6, 2017 13:35
@xxyzzzq
Copy link
Contributor Author

xxyzzzq commented Feb 6, 2017

This is also changing the behavior when a video starts autoplaying to no longer set the flag to false, right?

Yes, I feel the original flag "autoplaying flag" has some inconsistencies, so it is hard to tell what it really mean.

This is why I'm changing the name to "autoplay on demand flag" to "the element is in the autoplaying stage", so the user agent can autoplay it if they want if the flag is true.

If we keep the old behavior and set the flag to false, then we have to set it to true at some point (maybe when it becomes invisible). However I feel this is a bit overlapping with "eligible to autoplay" as it also checks the paused attribute.

@xxyzzzq
Copy link
Contributor Author

xxyzzzq commented Feb 6, 2017

Is this web compatible?

Yes, Safari on iOS already does this (using an equivalent implementation). So I think websites who care about the autoplay behavior should already know it.

Would it not be nice to have the ability to "auto pause" without autoplay?

Yes, it would be nice to have this. However we are targeting the autoplay attribute, which has very low percentage of usage compared to autoplay by play() method. Here we only want to improve the default implementation of the autoplay behavior if it is initiated by autoplay attribute. Websites who really care about the behavior could have their own implementations.

source Outdated
<li><span>Notify about playing</span> for the element.</li>

<li>Set the <span>autoplaying flag</span> to false.</li>
<li>Optionally, if the substeps are triggered when a <code>video</code> element <span
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an editorial nit, I think this would be better as a separate paragraph (stating "when the element no longer..." instead of "wait until the element no longer...") introducing a second set of substeps, instead of as a step inside the autoplay substeps. Then you don't need to define the "substeps for interrupting autoplay" either (unless you were planning on using those from another spec?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It's a bit hard to rephrase without the substep set names as they reference each other (run the other set after one set is finished). However I managed to do it. PTAL

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I'd like @zcorpan's signoff for media stuff if he has time.

Copy link
Member

@foolip foolip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we should make this change, just a bit of tinkering needed.

source Outdated

<ol>

<li>Set the <code data-x="dom-media-paused">paused</code> attribute to true.</li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should use https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps, but I guess that setting the "autoplay on demand flag" to false would prevent autoplay the next time the video intersects the viewport? It'd be fine to just say "invoke the internal pause steps and set the autoplay on demand flag to false" instead.

I think it would be good to point out that the steps for playing and pausing can be triggered many times. Because this inside an algorithm, my default assumption would be that one never jumps to an earlier step implicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, setting the paused attribute is a bit weird as it is intended to be used for reflecting instead of controlling the playback state.

It'd be fine to just say "invoke the internal pause steps and set the autoplay on demand flag to false" instead.

Did you mean "invoke the internal pause steps and set the autoplay on demand flag to true"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, true is the default state :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

source Outdated
<div w-nodev>

<p>All <span data-x="media element">media elements</span> have an <dfn>autoplaying flag</dfn>,
<p>All <span data-x="media element">media elements</span> have an <dfn>autoplay on demand flag</dfn>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old name was pretty bad, so allow me to bikeshed a little bit. In this context, I'd associate "on demand" with a user doing the demanding or perhaps video on demand as opposed to live. To call it "autoplay eligibility flag" would be an accurate and boring name. That's the best I can come up with, any other ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will be a bit confusing with the definition of "eligible for autoplay". Maybe name it "autoplay stage flag"? which is always true after loading and before the user explicitly call play() or pause(). The UA can autoplay at will if the flag is true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, one would have to pay attention to not confuse "eligible for autoplay" with the raw value of the flag. "The UA can autoplay at will if the flag is true" is precisely it, so maybe the "can autoplay flag"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@xxyzzzq
Copy link
Contributor Author

xxyzzzq commented Feb 7, 2017

Safari has an equivalent implementation. +@jernoble to look at this change and see if he's okay.

@xxyzzzq
Copy link
Contributor Author

xxyzzzq commented Feb 7, 2017

@foolip PTAL

the viewport</span> and, if the element is still <span>eligible for autoplay</span>, run the
substeps above. Optionally, when the element stops <span data-x="intersect the
viewport">intersecting the viewport</span>, and if the <span>can autoplay flag</span> is still
true and the <code data-x="attr-media-autoplay">autoplay</code> attribute is still specified,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@foolip I tend to remove the paused attribute from the "eligible for autoplay", so we can use:

  • Eligible for autoplay and paused attribute is true for starting autoplay
  • Eligible for autoplay and paused attribute is false for pausing autoplay

Does it sound good?

Copy link
Member

@foolip foolip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a few minor things with punctuation and moved+clarified the note about multiple play/pause. @xxyzzzq, can you check if it's OK before merging?

@foolip
Copy link
Member

foolip commented Feb 9, 2017

I have filed web-platform-tests/wpt#4772 to track the fact that it's not possible to write shared tests for this.

@foolip
Copy link
Member

foolip commented Feb 9, 2017

Ping @jernoble to check if this is close enough to what WebKit does.

@xxyzzzq
Copy link
Contributor Author

xxyzzzq commented Feb 9, 2017

@foolip LGTM. Thanks for the fixes 👍

@jernoble
Copy link

jernoble commented Feb 9, 2017

@foolip, AFAICT, this is close enough to what WebKit does on iOS.

@foolip
Copy link
Member

foolip commented Feb 9, 2017

@foolip foolip merged commit aba54ed into whatwg:master Feb 9, 2017
MXEBot pushed a commit to mirror/chromium that referenced this pull request Feb 16, 2017
In this CL, when a muted video is autoplaying from attribute, we
pause it when it comes off screen.

Intent to implement and ship: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/UtFM-kndhaI
Spec PR: whatwg/html#2324

BUG=683141

Review-Url: https://codereview.chromium.org/2654123002
Cr-Commit-Position: refs/heads/master@{#450707}
@alastor0325
Copy link

I think we should also consider whether the video is audible or not, because it's annoying that the audio track was also be paused when the video became invisible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition/proposal New features or enhancements topic: media

Development

Successfully merging this pull request may close these issues.

7 participants