Skip to content

Commit

Permalink
fix: allow captions in devices that use old chrome to be shown
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosVillasenor committed Aug 9, 2024
1 parent 57c27f8 commit f0089e8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/css/components/_text-track.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ video::-webkit-media-text-track-display {
text-align: center !important;
width: 80% !important;
}

.video-js .vjs-text-track-display > div {
top: 0;
right: 0;
bottom: 0;
left: 0;
}
30 changes: 30 additions & 0 deletions src/js/tracks/text-track-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,23 @@ class TextTrackDisplay extends Component {
}
this.updateForTrack(descriptionsTrack);
}

if (!window.CSS.supports('inset', '0')) {
const textTrack = window.document.querySelector('.vjs-text-track-display');
const player = window.document.querySelector('video-js');
const textTrackHeight = textTrack.getBoundingClientRect().height;

Check warning on line 326 in src/js/tracks/text-track-display.js

View check run for this annotation

Codecov / codecov/patch

src/js/tracks/text-track-display.js#L324-L326

Added lines #L324 - L326 were not covered by tests

// This styles are required to be inline
textTrack.style.position = 'relative';
textTrack.style.height = textTrackHeight + 'px';
textTrack.style.top = 'unset';

Check warning on line 331 in src/js/tracks/text-track-display.js

View check run for this annotation

Codecov / codecov/patch

src/js/tracks/text-track-display.js#L329-L331

Added lines #L329 - L331 were not covered by tests

if (player.classList.contains('vjs-fullscreen')) {
textTrack.style.bottom = textTrackHeight + 'px';

Check warning on line 334 in src/js/tracks/text-track-display.js

View check run for this annotation

Codecov / codecov/patch

src/js/tracks/text-track-display.js#L333-L334

Added lines #L333 - L334 were not covered by tests
} else {
textTrack.style.bottom = '0px';

Check warning on line 336 in src/js/tracks/text-track-display.js

View check run for this annotation

Codecov / codecov/patch

src/js/tracks/text-track-display.js#L336

Added line #L336 was not covered by tests
}
}
}

/**
Expand Down Expand Up @@ -484,6 +501,19 @@ class TextTrackDisplay extends Component {
this.updateDisplayState(track);
}
}

if (!window.CSS.supports('inset', '0')) {
const document_ = window.document;
const vjsTextTrackCue = document_.querySelector('.vjs-text-track-cue');

Check warning on line 507 in src/js/tracks/text-track-display.js

View check run for this annotation

Codecov / codecov/patch

src/js/tracks/text-track-display.js#L506-L507

Added lines #L506 - L507 were not covered by tests

if (vjsTextTrackCue) {
const insetStyles = vjsTextTrackCue.style.inset.split(' ');

Check warning on line 510 in src/js/tracks/text-track-display.js

View check run for this annotation

Codecov / codecov/patch

src/js/tracks/text-track-display.js#L509-L510

Added lines #L509 - L510 were not covered by tests

if (insetStyles.length === 3) {
Object.assign(vjsTextTrackCue.style, { top: insetStyles[0], right: insetStyles[1], bottom: insetStyles[2], left: 'unset' });

Check warning on line 513 in src/js/tracks/text-track-display.js

View check run for this annotation

Codecov / codecov/patch

src/js/tracks/text-track-display.js#L512-L513

Added lines #L512 - L513 were not covered by tests
}
}
}
}

}
Expand Down

0 comments on commit f0089e8

Please sign in to comment.