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: allow captions in devices that use old chrome to be shown #8826

Merged
merged 15 commits into from
Aug 26, 2024

Conversation

CarlosVillasenor
Copy link
Contributor

@CarlosVillasenor CarlosVillasenor commented Aug 9, 2024

Description

In the specific case of using an old chrome version this minor changes will allow the captions to be shown.

Specific Changes proposed

Small fix when using videojs in an old browser that does not support the css 'inset' property.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chrome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
    • Has no DOM changes which impact accessiblilty or trigger warnings (e.g. Chrome issues tab)
    • Has no changes to JSDoc which cause npm run docs:api to error
  • Reviewed by Two Core Contributors

Copy link

codecov bot commented Aug 9, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.46%. Comparing base (57c27f8) to head (4e8c5aa).
Report is 8 commits behind head on main.

Files Patch % Lines
src/js/tracks/text-track-display.js 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8826      +/-   ##
==========================================
+ Coverage   83.12%   84.46%   +1.33%     
==========================================
  Files         120      120              
  Lines        8052     9492    +1440     
  Branches     1931     2477     +546     
==========================================
+ Hits         6693     8017    +1324     
- Misses       1359     1475     +116     

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

@CarlosVillasenor CarlosVillasenor marked this pull request as ready for review August 13, 2024 03:02
@mister-ben
Copy link
Contributor

Would it work to put the changes to .vjs-text-track-display in updateDisplayOverlay() in this block before the return? Just to keep the alternate styles for the same element close to each other for maintainability.

if (!this.player_.videoHeight() || !window.CSS.supports('inset-inline: 10px')) {
return;
}

test/unit/tracks/text-track-display.test.js Outdated Show resolved Hide resolved
src/js/tracks/text-track-display.js Outdated Show resolved Hide resolved
src/js/tracks/text-track-display.js Outdated Show resolved Hide resolved
@@ -319,6 +320,23 @@ class TextTrackDisplay extends Component {
}
this.updateForTrack(descriptionsTrack);
}

if (browser.IS_SMART_TV && !window.CSS.supports('inset', '10px')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be any browser doesn't support inset, and not just smart TVs? Smart TVs are the only real reason to be using such old browser versions, but it's not inconceivable that people might test things destined for a smart TV on an old browser on desktop/browserstack etc.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, should be a feature test only, unless there's a good reason to only target TVs?
Below should be updated to match as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the PR to support this changes on any browser, I got to move the update of the styles of textTrackDisplay to add support when user switches to full screen, can this be re-reviewed?

Comment on lines 355 to 358
textTrackDisplay.style.position = 'relative';
textTrackDisplay.style.height = textTrackDisplayHeight + 'px';
textTrackDisplay.style.top = 'unset';
textTrackDisplay.style.bottom = '0px';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
textTrackDisplay.style.position = 'relative';
textTrackDisplay.style.height = textTrackDisplayHeight + 'px';
textTrackDisplay.style.top = 'unset';
textTrackDisplay.style.bottom = '0px';
tryUpdateStyle(textTrackDisplay, 'position', 'relative');
tryUpdateStyle(textTrackDisplay, 'height', textTrackDisplayHeight + 'px');
tryUpdateStyle(textTrackDisplay, 'top', 'unset');
tryUpdateStyle(textTrackDisplay, 'bottom', '0px');

this updates to use tryUpdateStyle for consistency with the rest of the code, but maybe that isn't really neccessary as the comment for tryUpdateStyle metions IE8 🤔

Copy link
Contributor Author

@CarlosVillasenor CarlosVillasenor Aug 14, 2024

Choose a reason for hiding this comment

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

added this change in the last commit, can this be re-reviewed?

@@ -46,3 +46,11 @@ video::-webkit-media-text-track-display {
text-align: center !important;
width: 80% !important;
}

.video-js .vjs-text-track-display > div {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does the div here represent? Do we want this CSS set always? Or maybe we could add a class name to this div in the scenario we want so we know it is SMART TV related..

I just want to be sure this does not have any unexpected side effects..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a div that is dynamically generated without a classname it is the parent of the vjs-text-track-cue, all of this styles are just backup styles, are all overwritten by inline styles except in old chrome devices.

Screenshot 2024-08-21 at 13 35 50

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I updated the PR to add those styles only when required, can this be re-reviewed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, I would maybe make that name more descriptive "vjs-text-track-display-inset" or something like that. Otherwise, nice work!

src/css/components/_text-track.scss Outdated Show resolved Hide resolved
Comment on lines 333 to 334
// Add custom class to textTrackDisplay div child for not inset support styles
textTrackDisplay.firstChild.classList.add('vjs-text-track-display-inset');
Copy link
Member

Choose a reason for hiding this comment

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

an alternative to adding this class is using css @supports. Then, this line won't be necessary and it could all be done in css.

Suggested change
// Add custom class to textTrackDisplay div child for not inset support styles
textTrackDisplay.firstChild.classList.add('vjs-text-track-display-inset');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated this in the last commit, can this be re-reviewed?

src/js/tracks/text-track-display.js Show resolved Hide resolved
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.

4 participants