whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.16k stars 2.69k forks source link

Pseudo elements for <video> content and controls #10507

Open jakearchibald opened 3 months ago

jakearchibald commented 3 months ago

What problem are you trying to solve?

I want to apply CSS filters/adjustments to <video> content without impacting the visual appearance of controls & subtitles.

In another use-case, I want to display: none the video content, as I'm writing to it a <canvas> with post-processing, but I'd still like to overlay the browser playback controls.

What solutions exist today?

You can recreate the controls and video controls yourself, then apply CSS filters etc to the <video>.

How would you solve it?

Give <video> pseudo-elements such as:

::cue already exists for text tracks.

::-webkit-media-controls is already a thing.

Anything else?

No response

jakearchibald commented 3 months ago

Couple of StackOverflow posts wanting this:

ydaniv commented 3 months ago

+1! Same goes for clipping and masking the content.

jakearchibald commented 3 months ago

A fun hack is to do something like:

video {
  overflow: visible;
  translate: -2000px 0;

  &::-webkit-media-controls {
    translate: 2000px 0;
  }
}

That gives you the controls without the video. You still need to draw the video to a canvas before you can filter it. And this hack doesn't work in Firefox.

lukewarlow commented 3 months ago

It's worth also noting that as part of the invokers/commands proposal a number of people are keen on the idea of commands for controlling media elements and this is in part because styling the built-ins is hard/impossible, any step in the right direction would be good.

annevk commented 3 months ago

cc @whatwg/media @whatwg/css