feat(player): replace native cues with custom subtitle renderer

This commit is contained in:
hibna
2026-02-12 19:56:46 +03:00
parent 83124fbd05
commit 961d9ac3b9
7 changed files with 362 additions and 189 deletions
+56 -124
View File
@@ -25,133 +25,65 @@
display: none !important;
}
::cue,
.video-element::cue {
.custom-subtitle-overlay {
position: absolute;
left: 0;
right: 0;
z-index: var(--player-z-subtitle);
display: flex;
justify-content: center;
padding: 0 18px;
pointer-events: none;
}
.custom-subtitle-overlay.bottom {
bottom: var(--player-subtitle-bottom);
transition: bottom var(--player-transition-fast) ease;
}
.video-player.controls-hidden .custom-subtitle-overlay.bottom {
bottom: var(--player-subtitle-bottom-hidden);
}
.custom-subtitle-overlay.top {
top: 24px;
}
.custom-subtitle-overlay.center {
top: 50%;
transform: translateY(-50%);
}
.custom-subtitle-stack {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
width: 100%;
max-width: min(92%, 1200px);
}
.custom-subtitle-cue {
display: inline-block;
max-width: 100%;
padding: 0.35em 0.75em;
border-radius: var(--player-radius-sm);
font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI',
'Roboto', 'Helvetica Neue', Arial, sans-serif !important;
font-size: 1.4rem !important;
font-weight: 500 !important;
line-height: 1.45 !important;
letter-spacing: 0.01em !important;
color: #ffffff !important;
background-color: rgba(15, 15, 15, 0.78) !important;
padding: 0.35em 0.75em !important;
border-radius: var(--player-radius-sm) !important;
text-shadow: none !important;
white-space: pre-line !important;
}
::-moz-cue,
.video-element::-moz-cue {
font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI',
'Roboto', 'Helvetica Neue', Arial, sans-serif !important;
font-size: 1.4rem !important;
font-weight: 500 !important;
line-height: 1.45 !important;
letter-spacing: 0.01em !important;
color: #ffffff !important;
background-color: rgba(15, 15, 15, 0.78) !important;
padding: 0.35em 0.75em !important;
border-radius: var(--player-radius-sm) !important;
text-shadow: none !important;
white-space: pre-line !important;
}
::cue(b),
::cue(strong),
.video-element::cue(b),
.video-element::cue(strong),
::-moz-cue(b),
::-moz-cue(strong) {
font-weight: 700 !important;
}
::cue(i),
::cue(em),
.video-element::cue(i),
.video-element::cue(em),
::-moz-cue(i),
::-moz-cue(em) {
font-style: italic !important;
}
::cue(u),
.video-element::cue(u),
::-moz-cue(u) {
text-decoration: underline !important;
}
.video-element::-webkit-media-text-track-container {
position: absolute !important;
left: 0 !important;
right: 0 !important;
bottom: var(--player-subtitle-bottom) !important;
width: 100% !important;
display: flex !important;
flex-direction: column !important;
align-items: center !important;
justify-content: center !important;
padding: 0 18px !important;
margin: 0 !important;
z-index: var(--player-z-subtitle) !important;
pointer-events: none !important;
transition: bottom var(--player-transition-fast) ease !important;
}
.video-player.controls-hidden .video-element::-webkit-media-text-track-container {
bottom: var(--player-subtitle-bottom-hidden) !important;
}
.video-element::-webkit-media-text-track-display {
width: 100% !important;
max-width: 100% !important;
display: flex !important;
flex-direction: column !important;
align-items: center !important;
justify-content: center !important;
margin: 0 !important;
padding: 0 !important;
text-align: center !important;
}
video::-moz-text-track-display,
.video-element::-moz-text-track-display {
position: absolute !important;
left: 0 !important;
right: 0 !important;
bottom: var(--player-subtitle-bottom) !important;
width: 100% !important;
display: flex !important;
flex-direction: column !important;
align-items: center !important;
justify-content: center !important;
padding: 0 18px !important;
margin: 0 !important;
text-align: center !important;
z-index: var(--player-z-subtitle) !important;
pointer-events: none !important;
transition: bottom var(--player-transition-fast) ease !important;
}
.video-player.controls-hidden video::-moz-text-track-display,
.video-player.controls-hidden .video-element::-moz-text-track-display {
bottom: var(--player-subtitle-bottom-hidden) !important;
}
.video-element:fullscreen::cue,
:fullscreen .video-element::cue,
::-moz-cue:fullscreen,
video:fullscreen::-moz-cue,
:fullscreen ::-moz-cue {
font-size: 1.8rem !important;
padding: 0.4em 0.9em !important;
'Roboto', 'Helvetica Neue', Arial, sans-serif;
font-size: 1.4rem;
font-weight: 500;
line-height: 1.45;
letter-spacing: 0.01em;
color: #fff;
background-color: rgba(15, 15, 15, 0.78);
text-align: center;
text-shadow: none;
white-space: pre-line;
word-wrap: break-word;
}
@media (max-width: 640px) {
::cue,
.video-element::cue,
::-moz-cue,
.video-element::-moz-cue {
font-size: 1.2rem !important;
.custom-subtitle-cue {
font-size: 1.2rem;
}
}