Re: [csswg-drafts] [web-animations-2][css-animations-2] Allow controlling video playback via an animation timeline (#11611)

> ([#](https://github.com/w3c/csswg-drafts/issues/11611#issue-2821305114)) Possibly also with css support, e.g.:
> 
> #my-video {
>   video-timeline: view();
> }

Bikeshedding: maybe `playback-timeline` to keep it open to other media elements?

---

> ([#](https://github.com/w3c/csswg-drafts/issues/11611#issuecomment-2628757656)) For what it's worth, when we designed the Web Animations API, the intention was that driving video playback would happen via different types of effects and you'd synchronize it with other animations via group effects.

I feel like that’s the type of thing authors would be able to make themselves using an `onProgress` event, something that’s been part of the discussion for `CustomEffect` (#6861). I also saw a similar request in #9974 which would be solved by `onProgress`.

_(Also see https://brm.us/scroll-driven-video#the-demos where I built this type of thing – using a `rAF` lacking any `onProgress` event)_ 

My feeling here is that instead of trying to determine all sorts of new `*Effect` interfaces and requiring authors to overhaul their code to use a `GroupEffect`, this can all be unified in `onProgress`.

If the `GroupEffect` is considered to be more viable than `onProgress`, I think we should offer authors a `BaseEffect` class that they can extend in order to roll their own `VideoEffect` to drive a video progressing based on an animation. This way they would not need to wait for all vendors to implement that specific type of `Effect`, or any other new type of `Effect`.

To make these effects available in CSS, they could register it using something like `CSS.registerAnimationEffect(new VideoEffect(document.querySelector('#my-video')), '--video');` … which smells a lot like Houdini at that point :)

_(Personally I believe an `onProgress` better fits the mental model authors have about all this, in which they want to _“take an animation (effect) and map its progress to something else”_. Yes, `GroupEffect` allows more composability, but I believe that’s only for “advanced” users.)_

---

Winging back to Rob’s proposal: What I like about it is that it allows an author to take a `ViewTimeline`/`ScrollTimeline` and use that as the timeline for the media file, without requiring some animation to run. This _“an animation must be present”_ requirement has been a recurring point of friction for me, as I sometimes only need the timeline in order to drive things. In those cases I end up setting a dummy animation to goes from opacity 1 to opacity 1 on some element, which seems a bit stupid to be able to achieve my goal.

-- 
GitHub Notification of comment by bramus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11611#issuecomment-2643021355 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 7 February 2025 13:59:04 UTC