w3c / w3c/csswg-drafts

[css-contain-2]: Pause media playback in iframes hidden by content-visibility:hidden

Open
#6,468 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Closed Accepted by CSSWG Resolution css-contain-2 Needs Edits
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

https://drafts.csswg.org/css-contain/#content-visibility

We have a use case where we would like the ability to pause playback of video when we mark a cross-origin <iframe> as being content-visibility: hidden.

Eg, we include an iframe to youtube video, which the user then plays. After playing, the user becomes disinterested and scrolls on to the rest of the document. After the users is far enough away, we manually mark youtube iframe with content-visibility: hidden. Ideally, this would pause the playback so it's no longer taking resources, audio would stop playing, and the state would be paused. If the user were to scroll back to the youtube iframe, they'd find it in the paused state at the exact point they scrolled away.

In order to achieve this currently, we actually remove the entire iframe from the document. This guarantees the media will stop playback, but it also loses the current track position. If the user scrolls back to the the youtube iframe, they'll find it reset to the 0s mark, which isn't a great experience for them.

/cc @chrishtr

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CSS Containment specification section on content-visibility and review the issue's iframe and media-playback use case. Determine how hidden cross-origin iframes should affect playback while preserving their position; done requires an agreed specification change, not an implementation or named test.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.