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

fix(mux-player): use CSS to disable subtitle shifting for iOS in fullscreen. #958

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mux-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"dependencies": {
"@mux/mux-video": "0.20.0",
"@mux/playback-core": "0.25.0",
"media-chrome": "~3.2.3"
"media-chrome": "~3.2.5"
},
"devDependencies": {
"@mux/esbuilder": "0.1.0",
Expand Down
16 changes: 14 additions & 2 deletions packages/mux-player/src/themes/classic/classic.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,28 @@

/* 0.433s is the transition duration for VTT Regions.
* Borrowed here, so the captions don't move too fast. */
media-controller ::slotted([slot='media']) {
media-controller {
--media-webkit-text-track-transition: transform 0.433s ease-out 0.3s;
}
media-controller:is([mediapaused],:not([userinactive])) ::slotted([slot='media']) {
media-controller:is([mediapaused],:not([userinactive])) {
/* 42px is the height of the control bar and progress bar
* with an additional 5px as a buffer, to get 47px */
--media-webkit-text-track-transform: translateY(-47px);
--media-webkit-text-track-transition: transform 0.15s ease;
}

/*
* CSS specific to iOS devices.
* See: https://stackoverflow.com/questions/30102792/css-media-query-to-target-only-ios-devices/60220757#60220757
*/
@supports (-webkit-touch-callout: none) {
/* Disable subtitle adjusting for iOS Safari */
media-controller[mediaisfullscreen] {
--media-webkit-text-track-transform: unset;
--media-webkit-text-track-transition: unset;
}
}

:host media-time-range {
color: var(--_primary-color);
--media-range-thumb-opacity: 0;
Expand Down
16 changes: 14 additions & 2 deletions packages/mux-player/src/themes/gerwig/gerwig.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,27 @@
* 0.433s is the transition duration for VTT Regions.
* Borrowed here, so the captions don't move too fast.
*/
media-controller ::slotted([slot='media']) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NOTE: Although this change isn't technically required, custom CSS properties (aka "CSS variables") inherit, so removing the narrower selection since it's both unnecessary and adds specificity that is harder to override.

media-controller {
--media-webkit-text-track-transform: translateY(0) scale(0.98);
--media-webkit-text-track-transition: transform 0.433s ease-out 0.3s;
}
media-controller:is([mediapaused], :not([userinactive])) ::slotted([slot='media']) {
media-controller:is([mediapaused], :not([userinactive])) {
--media-webkit-text-track-transform: translateY(-50px) scale(0.98);
--media-webkit-text-track-transition: transform 0.15s ease;
}

/*
* CSS specific to iOS devices.
* See: https://stackoverflow.com/questions/30102792/css-media-query-to-target-only-ios-devices/60220757#60220757
*/
@supports (-webkit-touch-callout: none) {
/* Disable subtitle adjusting for iOS Safari */
media-controller[mediaisfullscreen] {
--media-webkit-text-track-transform: unset;
--media-webkit-text-track-transition: unset;
}
}

media-time-range {
--media-box-padding-left: 6px;
--media-box-padding-right: 6px;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11192,10 +11192,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b"
integrity sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==

media-chrome@~3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/media-chrome/-/media-chrome-3.2.3.tgz#581d3cc0ea4994838884ac3d769b95cc50954c1e"
integrity sha512-DlOlyciT5YgOn5cwGvLWz+OVUVgvyxsRLtfpIQJ11F10+Ix7tDjEqMWsnkL81be9iD3uh/SN35TIk2pRvvEAig==
media-chrome@~3.2.5:
version "3.2.5"
resolved "https://registry.yarnpkg.com/media-chrome/-/media-chrome-3.2.5.tgz#657722a216e3c0f877d9522fce7425e25da7e137"
integrity sha512-tTsgS7x77Bn4p/wca/Si/7A+Q3z9DzKq0SOkroQvrNMXBVyQasMayDcsKg5Ur5NGsymZfttnJi7tXvVr/tPj8g==

media-tracks@~0.3.2:
version "0.3.2"
Expand Down
Loading