Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/default duration #779

Merged
merged 5 commits into from
Dec 5, 2023
Merged

Conversation

cjpillsbury
Copy link
Collaborator

@cjpillsbury cjpillsbury commented Dec 5, 2023

Adds support for defaultduration to apply before media is loaded.

NOTE: The <media-time-range> can still be interacted with before the media has loaded, but that was already true.

Copy link

vercel bot commented Dec 5, 2023

@cjpillsbury is attempting to deploy a commit to the Mux Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Dec 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
media-chrome ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2023 9:16pm
media-chrome-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2023 9:16pm

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (e1d6377) 78.67% compared to head (feddaf9) 78.65%.
Report is 2 commits behind head on main.

❗ Current head feddaf9 differs from pull request most recent head fe30917. Consider uploading reports for the commit fe30917 to get more accurate results

Files Patch % Lines
src/js/controller.js 60.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #779      +/-   ##
==========================================
- Coverage   78.67%   78.65%   -0.03%     
==========================================
  Files          58       58              
  Lines       10627    10644      +17     
==========================================
+ Hits         8361     8372      +11     
- Misses       2266     2272       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -31,13 +31,14 @@
<body>
<main>
<h1>Media Chrome Advanced Video Usage Example</h1>
<media-controller defaultsubtitles>
<media-controller defaultsubtitles defaultduration="134">
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: we can revert this if preferred, though I think it might be a good example for advanced.

}

// Apply defaultDuration if it's set and the media is not yet ready
if (!(media.readyState || Number.isNaN(defaultDuration))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not rely on media.duration? media.duration >= 0 and not NaN
could backfire with custom media elements that have a limited media API

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting thought! I think readyState better represents the actual conditions, but only relying on duration sounds like it would be good simply because it reduces the barrier of entry for custom slotted media elements' API. technically 0 duration media is valid, but I think we can ignore that wild scenario unless/until it comes up. Sold.

Copy link
Collaborator

Choose a reason for hiding this comment

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

right 0 would be wild :) was thinking current time

Copy link
Collaborator

@luwes luwes left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@heff heff left a comment

Choose a reason for hiding this comment

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

A few questions but lgtm.

(!media ||
!media.duration ||
Number.isNaN(media.duration) ||
!Number.isFinite(media.duration))
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the source is live (Infinite), would this screw up some things?

}

// If `defaultduration` is unset, we still want to propagate `NaN`
// for some cases to ensure appropriate media state receiver updates.
// TODO: What if duration is infinity/live? (heff)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, ha. Still a future us problem? Or can we remove this note?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't wanna be presumptuous, but we can probably remove it. We expect to strip live infinity in our architecture rn and don't have a story for live + our components that (typically) expect a (finite) duration. I'll drop it before merging.

@cjpillsbury cjpillsbury merged commit b5a8af6 into muxinc:main Dec 5, 2023
1 check passed
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.

3 participants