Re: [csswg-drafts] [selectors-4] additional resource state pseudo-classes for media elements (#3821)

The CSS Working Group just discussed `additional resource state pseudo-classes for media elements`, and agreed to the following:

* `RESOLVED: Add :muted, :seeking, and :stalled pseudos.`

<details><summary>The full IRC log of that discussion</summary>
&lt;heycam> Topic: additional resource state pseudo-classes for media elements<br>
&lt;heycam> github: https://github.com/w3c/csswg-drafts/issues/3821<br>
&lt;bkardell_> s/JS Foundation/Open JS Foundation<br>
&lt;iank_> Ian Kilpatrick, Google<br>
&lt;heycam> hober: we currently have playing and pause pseudo classes, which media elements match when they are playing or paused<br>
&lt;heycam> ... the use case is, things like custom media controls, with a unified play/pause button<br>
&lt;heycam> ... there are a handful of other common media element states that have a similar rationale for exposing to CSS<br>
&lt;heycam> ... stuff that people are currently using script for<br>
&lt;heycam> ... this issue is the 3 easy ones<br>
&lt;heycam> ... 1 is whether or not the element is muted<br>
&lt;heycam> ... you may have a mute button, styled volume slider<br>
&lt;heycam> ... very similar to playing/paused<br>
&lt;heycam> ... hope it's uncontroversial<br>
&lt;heycam> ... other 2 are a bit weird<br>
&lt;heycam> ... the HTMl spec has a concept of media being stalled<br>
&lt;heycam> ... and you can see examples of custom UI when media is stalled on popular sites like YouTube, netflix<br>
&lt;heycam> ... the spinner looks different<br>
&lt;heycam> ... if we could provide styling for that it would be nice<br>
&lt;tantek> q+ to ask about "buffering" vs. "streaming connection broken" (have seen different UI)<br>
&lt;heycam> ... the 3rd one is: media elements have a seeking state, which is useful for cases like when you are displaying custom controls, but seeking is happening due to other controls<br>
&lt;heycam> ... maybe seeking with a remote control, but you want you custom control to do a different thing<br>
&lt;tantek> FYI: https://html.spec.whatwg.org/multipage/media.html#htmlmediaelement<br>
&lt;heycam> ... so the HTML spec has the right hooks here<br>
&lt;heycam> ... just need something in CSS to expose them<br>
&lt;heycam> ... so 3 proposed pseudo classes: muted, stalled, seeking<br>
&lt;heycam> florian: what is seeking as a state<br>
&lt;heycam> hober: while you're seeking.  if you using the scrubber<br>
&lt;heycam> AmeliaBR: like an active state<br>
&lt;fremy> q+ to talk about additional states<br>
&lt;TabAtkins> q+<br>
&lt;Rossen_> ack dbaron<br>
&lt;Zakim> dbaron, you wanted to ask whether :muted would cover tab-level, app-level, or system-level muting (I suspect not, but want to ask)<br>
&lt;heycam> dbaron: there's ofte na lot of ways to mute something<br>
&lt;heycam> ... my guess here this ignores your tab is muted, hardware control is muted, is that right?<br>
&lt;Rossen_> q?<br>
&lt;heycam> hober: I think that's right.  but I'm not sure.  I think this shouldb e tied to the host lang's definition<br>
&lt;heycam> dbaron: ok so the HTML definition<br>
&lt;tantek> ack tantek<br>
&lt;Zakim> tantek, you wanted to ask about "buffering" vs. "streaming connection broken" (have seen different UI)<br>
&lt;Rossen_> ack tantek<br>
&lt;heycam> tantek: I like the general direction of the proposal, +1 on them.  even the less common features<br>
&lt;heycam> ... this shook loose memories of things I worked on right before Mozilla, doing HTML5 consulting, setting up video UIs<br>
&lt;heycam> ... took a bunch of notes which I forgot about that<br>
&lt;heycam> ... I needed this in 2010<br>
&lt;heycam> ... the :stalled pseudo class, I've seen different UI between buffering to show something, vs the network connection is gone<br>
&lt;heycam> ... even if you're in this "I want to play" state<br>
&lt;heycam> ... wondering if it's worth distinguishing<br>
&lt;heycam> hober: I agree there's a use case there<br>
&lt;florian> +1 to tantek<br>
&lt;heycam> ... I think network state is a little more general.  that's going to affect hte page, not just the media elements<br>
&lt;heycam> tantek: but that's a differnt can of worms<br>
&lt;heycam> hober: I'd rather tacklet that as a different thing<br>
&lt;Rossen_> q?<br>
&lt;heycam> tantek: I'm saying I'd rather not, since it is a can of worms<br>
&lt;heycam> hober: could you propose another pseudo for this?<br>
&lt;heycam> tantek: do you want one pseudo that means either of that?  two for the specific states?<br>
&lt;heycam> hober: I'd be happy to delegate this to HTML<br>
&lt;heycam> ... some HTML spec refactoring is needed anyway, for stalled<br>
&lt;heycam> ... from our perspective, we'd defer to the host language<br>
&lt;jensimmons> do these apply to &lt;audio> as well as &lt;video>? I’d assume so…<br>
&lt;heycam> tantek: specifially the HTML media element interface?<br>
&lt;heycam> hober: yes<br>
&lt;jensimmons> q+<br>
&lt;heycam> emilio: images have differnet set of states.  broken, loaded.  Gecko hsa internal pseudos for these<br>
&lt;Rossen_> q?<br>
&lt;heycam> ... I wonder if it is useful to try to expose a common set of pseudos<br>
&lt;heycam> fremy: I was going ot suggest the same<br>
&lt;heycam> hober: in the past when this has come up, we've agreed we should have more general subresource state exposing<br>
&lt;heycam> ... was hoping to not get bogged down on that too much<br>
&lt;heycam> ... there's specific use cases for media in custom media controls<br>
&lt;tantek> note that the HTMLMediaElement does distinguish network state a bit:  NETWORK_EMPTY, NETWORK_IDLE, NETWORK_LOADING, NETWORK_NO_SOURCE<br>
&lt;heycam> ... I agree it should be coherent with a more general thing<br>
&lt;heycam> ... so we should keep that in mind<br>
&lt;heycam> ... but the last few times it's come up over 10 years, we end up not doing it<br>
&lt;dbaron> https://github.com/w3c/csswg-drafts/issues/3134 is about image state pseudo-classes<br>
&lt;Rossen_> ack fremy<br>
&lt;Zakim> fremy, you wanted to talk about additional states<br>
&lt;heycam> fremy: we don't need to standardize pseudos for all possible cases<br>
&lt;jensimmons> anything to make doing this kind of stlying possible, without replacing everything with JS, would be ideal: https://thewebahead.net/110<br>
&lt;heycam> ... you say you're sticking to the HTML spec's state.  ther's already an error state in there<br>
&lt;heycam> hober: I'm happy for someone to propose those<br>
&lt;heycam> fremy: seems reasonable to want to style them differently if you're on the network, etc.<br>
&lt;heycam> ... in the specific cases for media controls you do want to know about the network state<br>
&lt;heycam> ... in my initial proposal it was with video in mind.  I think it's a good idea to see how we can map them<br>
&lt;heycam> ... if you end up in an error state, you want to show that in the UI<br>
&lt;tantek> q+ to ask if :seeking is *while* the user is dragging the seeker, only upon release, or both?<br>
&lt;heycam> TabAtkins: hober's list of things are video specific<br>
&lt;Rossen_> ack TabAtkins<br>
&lt;heycam> ... two specific questions<br>
&lt;jensimmons> q-<br>
&lt;heycam> ... 1st, the current definition of playing says it subsumes seeking and stalled<br>
&lt;heycam> ... keeping that?<br>
&lt;heycam> hober: yes<br>
&lt;heycam> TabAtkins: ok cool.  2nd, :muted is good, do we want a general volume state?  low-volume high-volume?<br>
&lt;heycam> hober: I think it's fairly common for there to be a separate mute butotn.  and it doesn't seem harmful to have this<br>
&lt;heycam> TabAtkins: not saying as a replacement<br>
&lt;heycam> hober: think it totally makese snse.  the other proposal is related to volume, but it's a bit weirder than what you are proposing<br>
&lt;Rossen_> q?<br>
&lt;heycam> TabAtkins: I'll file a separate issue<br>
&lt;heycam> jensimmons: would this apply to audio?<br>
&lt;heycam> hober: it will<br>
&lt;Rossen_> q?<br>
&lt;heycam> TabAtkins: but not all resources in general<br>
&lt;Rossen_> qqqqqqq???<br>
&lt;tantek> I'd like to consider splitting :stalled into :buffering and :stalled distinct states, where :buffering means there is still some data coming from the network, just not enough to play, and :stalled is actually stalled including not getting data from the network<br>
&lt;heycam> jensimmons: +1<br>
&lt;tantek> q?<br>
&lt;heycam> tantek: nitpick, but is :seekin while they're dragging?  not when they let go?<br>
&lt;heycam> hober: yes<br>
&lt;heycam> tantek: the specific request then is to split stalled into buffering and stalled<br>
&lt;florian> q?<br>
&lt;heycam> ... as a webdev, that's the two states I want to hook into<br>
&lt;heycam> hober: can't remmeber off hand if they are distinct states in HTML<br>
&lt;heycam> ... anything you can reasonably map it makes sense<br>
&lt;AmeliaBR> q+ for the unofficial q<br>
&lt;heycam> florian: I think the stalled state, when it means buffering, is a variant of playing<br>
&lt;heycam> ... it's a "trying to play" state<br>
&lt;heycam> tantek: it's not playing<br>
&lt;heycam> florian: the play/pause button is in the play state<br>
&lt;heycam> hober: there's all sound like issues to file in the HTML spec<br>
&lt;heycam> AmeliaBR: overall my main concern is there needs to be clear definitions of what all these mean<br>
&lt;heycam> ... shouldn't be exposing things that aren't exposed other ways<br>
&lt;heycam> ... I assume most of these there are events you can listen to when these states change<br>
&lt;heycam> ... if that's not true, don't want to make people poll for pseudo state matching<br>
&lt;heycam> hober: I tried to limit to the state that is already exposed<br>
&lt;chris> rrsagent, here<br>
&lt;tantek> HTMLMediaElement does have both networkState and readyState which are finer grained<br>
&lt;heycam> ... people are already doing this with script, but perhaps a few frame sbehind<br>
&lt;heycam> florian: not saying we should differ from HTML.  but just not naively expose every state<br>
&lt;heycam> AmeliaBR: tantek brought up a point, if you want to get more granualr, a general stalled class, then one a parenthesized one later<br>
&lt;heycam> tantek: since we only have 2 states would like to keep them orthogonal<br>
&lt;heycam> ... and looking at the HTML spec now, it's more granular than we need<br>
&lt;heycam> ... per your request, I believe this information is avialable to script right onw, but you need to combine readyState and networkState to figure out what's oging on<br>
&lt;heycam> ... I'm saying let's expose a higher level state concept to UI<br>
&lt;Rossen_> q?<br>
&lt;heycam> ... HTML has these states already, but as a developer you need to check those combinations<br>
&lt;florian> +1 to tantek<br>
&lt;heycam> ... I'm saying CSS should simplify that<br>
&lt;heycam> bkardell_: why only in CSS?<br>
&lt;heycam> tantek: we want to solve use cases, not plumbing<br>
&lt;heycam> AmeliaBR: can you write up a table with the combinations?<br>
&lt;heycam> hober: can you file an issue for buffering?<br>
&lt;heycam> florian: I'm confused about resolving on stalled before knowing what it maps to<br>
&lt;heycam> hober: it's just the HTML stalled state<br>
&lt;heycam> florian: my understanding there are low level bits, and the one called stalled covers more than one use case<br>
&lt;heycam> ... if there are two bits maybe we don't want to expose these two things separately?<br>
&lt;heycam> bkardell_: we shouldn't overload them with the same name...<br>
&lt;heycam> hober: the name stalled in CSS should be the same as stalled in HTML<br>
&lt;AmeliaBR> `:stalled` vs `:buffering` and `:broken-stream`<br>
&lt;heycam> florian: then maybe we should have two different ones, not called stalled<br>
&lt;heycam> tantek: are you asking for new HTML specs rathe rthan new property values?<br>
&lt;heycam> hober: I'm not asking for anything in HTML<br>
&lt;heycam> ... the 3 things I've proposed map to existing concepts in HTML<br>
&lt;heycam> tantek: buffering is expoesd, but there's no event for it<br>
&lt;heycam> hober: I think it would be weird to have a straightforward way ot look for buffering in CSS and not have corresponding APIs<br>
&lt;heycam> tantek: there is<br>
&lt;heycam> hober: but you have to be clever by combining state<br>
&lt;heycam> tantek: DOM APIs are meant to be minimal and fine grained.  but not for CSS<br>
&lt;heycam> hober: you should propose the :buffering pseudo, it sounds great<br>
&lt;heycam> florian: I'm also hearing that the stalled concept, if we're going ot have :buffering vs not having it<br>
&lt;heycam> hober: I don't think it impacts that at all.  stalled has a clear definition in HTML, that's what it should be<br>
&lt;heycam> AmeliaBR: you're still arguing it for it to be the superclass<br>
&lt;heycam> florian: I am arging to go from use cases<br>
&lt;heycam> ... and if it maps to several bits in HTML, that should be ok, but not name them confusingly<br>
&lt;tantek> HTMLMediaElement summarizes stalled event as "The user agent is trying to fetch media data, but data is unexpectedly not forthcoming. "<br>
&lt;tantek> which reflects the meaning that I'm proposing<br>
&lt;heycam> ... but whether it's useful to expose a single bit just because, we shouldn't<br>
&lt;tantek> and is not inclusive of :buffering<br>
&lt;heycam> hober: I'm not proposing that<br>
&lt;heycam> ... I'm saying netflix has stalled UI, it's a common UI pattern, we have a definition in the spec<br>
&lt;tantek> Netflix has both stalled and buffering UIs - they're different<br>
&lt;heycam> florian: what is the use case?  does HTML solve that use case already?<br>
&lt;tantek> Netflix puts up an error when stalled (sorry no data or something), while buffering it shows a spinner and %<br>
&lt;heycam> florian: from the use case PoV, the buffering/stuck things are different<br>
&lt;heycam> hober: so propose a buffering thing<br>
&lt;heycam> ... I'm trying to do the opposite of stop energy here.  if you propose it, I'll +1 it<br>
&lt;heycam> florian: if the stalled class means either buffering or stuck ...<br>
&lt;heycam> Rossen_: the stalled event in HTML has a clear definition<br>
&lt;tantek> To be clear I am supportive of :stalled as defined in HTML because it is NOT inclusive of :buffering<br>
&lt;heycam> ... the proposal here is to map a pseudo to this<br>
&lt;heycam> ... that is all that is being proposed, the same way we're proposing for :muted, and :seeking<br>
&lt;AmeliaBR> From HTML:<br>
&lt;AmeliaBR> The stall timeout is a user-agent defined length of time, which should be about three seconds. When a media element that is actively attempting to obtain media data has failed to receive any data for a duration equal to the stall timeout, the user agent must queue a task to fire an event named stalled at the element.<br>
&lt;emilio> q+<br>
&lt;heycam> ... if there are other states in the media element that need to be exposed through events that will eventually map to pseudos, that's great.  file HTML issues to add events so script and CSS can benefit from them<br>
&lt;heycam> ... what we have right now satisfies the use cases brought forward<br>
&lt;heycam> fremy: your summary is why I'm confused.  you're saying what's in the spec solves the use cases, but I haven't seen the proof of that<br>
&lt;heycam> ... but i will trust hober on this<br>
&lt;heycam> hober: I apologize for the arugmnet from authority, I'm not the one working on this, I took this from media engineers from Mozilla, Google and Apple, and agreed to write it up for them<br>
&lt;heycam> emilio: :muted has a clear definition, since there's is HTMLMediaElement.muted<br>
&lt;heycam> ... :stalled only says when to fire the event, not when to remove it<br>
&lt;heycam> hober: yes I need to follow up with an HTML issue to expose a spec hook to latch on to<br>
&lt;heycam> ... it would be an editorial change to HTML<br>
&lt;heycam> RESOLVED: Add :muted, :seeking, and :stalled pseudos.<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3821#issuecomment-498683965 using your GitHub account

Received on Tuesday, 4 June 2019 14:00:09 UTC