Skip to content

Conversation

@spuppo-mux
Copy link
Contributor

@spuppo-mux spuppo-mux commented Dec 3, 2025

Closes #1238

The purpose of this PR is to expose hls.capLevelToPlayerSize property while maintaining the current behavior (if nothing is set, hls.capLevelToPlayerSize = true and we use our MinCapLevelController instead of HLS's default controller).

Added two new attributes cap-level-to-player-size and disable-cap-level-to-player-size; the latter mainly to be used on React components.

Web Components (<mux-video> and <mux-player> )

  • cap-level-to-player-size
    • If present will set hls.capLevelToPlayerSize when the HLS element is initialized using its own default CapLevelController. Note: If present will be true unless set to the string "false".
    • If not present, hls.capLevelToPlayerSize is set to true and MinCapLevelController is used instead.
  • disable-cap-level-to-player-size If present (and not set to "false"), will have the same behavior as setting cap-level-to-player-size="false". Takes precedence over cap-level-to-player-size.

React Components (MuxVideo and MuxPlayer)

  • Note: On the React Components setting reactAttribute={false} is equivalent to setting react-attribute=undefined on the Web Components.
  • capLevelToPlayerSize : boolean | undefined
    • If present (true): sets hls.capLevelToPlayerSize to true and sets HLS's default CapLevelController.
    • If not present (false or undefined): hls.capLevelToPlayerSize is set to true and MinCapLevelController is used instead.
  • disableCapLevelToPlayerSize : boolean | undefined
    • If present (true): sets hls.capLevelToPlayerSize to false and sets HLS's default CapLevelController.
    • If not present (false or undefined): Does nothing.

For both cases (React and Web Components), getting the capLevelToPlayerSize property will return:

  • false if disableCapLevelToPlayerSize=true;
  • whatever is set on the _hlsConfig.capLevelToPlayerSize if that value is defined;
  • whether that element's cap-level-to-player-size attribute !== "false" otherwise.

@vercel
Copy link

vercel bot commented Dec 3, 2025

@spuppo-mux is attempting to deploy a commit to the Mux Team on Vercel.

A member of the Team first needs to authorize it.

@snyk-io
Copy link

snyk-io bot commented Dec 3, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@spuppo-mux spuppo-mux force-pushed the feat/capLevelToPlayerSize branch from 87a05b5 to 73eb9b5 Compare December 3, 2025 16:17
@spuppo-mux spuppo-mux force-pushed the feat/capLevelToPlayerSize branch from 5a64c0e to 3e53889 Compare December 8, 2025 21:55
@spuppo-mux spuppo-mux marked this pull request as ready for review January 9, 2026 15:00
@spuppo-mux spuppo-mux requested a review from a team as a code owner January 9, 2026 15:00
@spuppo-mux spuppo-mux requested a review from luwes January 9, 2026 16:21
value=""
checked={value === undefined}
/>
<label htmlFor={`${name}-none-control`}>None</label>
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: 😎 glad you acknowledged the "3rd state" of "optional booleans" (aka "unset")

Copy link
Contributor

@cjpillsbury cjpillsbury left a comment

Choose a reason for hiding this comment

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

I'm realizing this isn't in line with what's discussed in #1238. We shouldn't be using string values for booleans, and we shouldn't be adding disable-cap-level-to-player-size yet unless there is no way or relying on JavaScript to set the value to false. This should resolve our current pain points, and we can add additional props if/when needed. If this won't work or if you have questions or confusions here, please reach out.

type="radio"
onChange={() => {
const changeValue = enumValue;
console.log("Selecting value:", changeValue, toChangeObject(name, changeValue));
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick(blocking): remove the console.log before merging

backward-seek-offset={10}
max-auto-resolution="720p"
cap-level-to-player-size={capLevelToPlayerSize ? true : undefined}
disable-cap-level-to-player-size={capLevelToPlayerSize === false ? true : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick(blocking): should this still exist? I thought we were descoping this for the initial implementation.

// envKey="mux-data-env-key"
controls
capLevelToPlayerSize={capLevelToPlayerSize === true}
disableCapLevelToPlayerSize={capLevelToPlayerSize === false}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick(blocking): same as above

cjpillsbury added a commit that referenced this pull request Jan 16, 2026
Exposes hls.js's `capRenditionToPlayerSize` option with a Mux-optimized
default.

Closes #1238 (based off of initial effort from @spuppo-mux in #1251)

### Behavior

| Value | Behavior |
|-------|----------|
| `undefined` (default) | Caps to player size, 720p minimum floor |
| `true` | Standard hls.js capping (may go below 720p) |
| `false` | No capping |

### Test plan

- [ ] `npm run dev` → http://localhost:3000/MuxPlayer
- [ ] Toggle "Cap Level To Player Size" between None/true/false
- [ ] Verify no console errors
- [ ] Verify config:
`document.querySelector('mux-player').media.nativeEl._hls.config.capLevelToPlayerSize`
- [ ] Trigger a rendition switch/re-selection via ABR - e.g. open Chrome
Dev Tools, resize player size, seek backwards during playback to prompt
segment reloading, and confirm that rendition does(n't) get capped under
different permutations

---------

Co-authored-by: Santiago Puppo <[email protected]>
@spuppo-mux
Copy link
Contributor Author

Closing as this was fixed on 9dfac1b

@spuppo-mux spuppo-mux closed this Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Expose a capLevelToPlayerSize property and attribute on Mux media elements

3 participants