fix(sabr): correct per-segment URIs and control-bar play button size

Segment index parsers (mp4/webm) declared the per-segment URI array with
`var` inside the loop, so every SegmentReference's getUris() closure
captured the same function-scoped binding and returned the LAST segment's
URL. YouTube received the final segment's startTimeMs/sq for every
segment, replied with policy-only UMP (no media), and the player looped
forever on a black screen ("SABR throttled by YouTube"). Use `let`
(block-scoped, fresh per iteration) to match FreeTube's `const`.

Also scope the big centered play button styling to
`.shaka-play-button-container`; the bare `.shaka-play-button` selector
also matched the control-bar play button (48px siblings), oversizing it
to ~54px and pushing it out of alignment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Emilien 2026-06-28 17:36:52 +02:00
parent 9fbe812899
commit e3b3e68380
3 changed files with 14 additions and 5 deletions

View File

@ -163,7 +163,10 @@
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.shaka-play-button { /* Scope to the big centered play button only. The control-bar play button
shares the .shaka-play-button class, so an unscoped rule here oversizes it
(1.5em + 1.5em padding = 4.5em 54px vs the 48px control-bar siblings). */
.shaka-play-button-container .shaka-play-button {
background-color: rgba(35, 35, 35, 0.75) !important; background-color: rgba(35, 35, 35, 0.75) !important;
border-radius: 0.3em !important; border-radius: 0.3em !important;
width: 1.5em !important; width: 1.5em !important;
@ -172,7 +175,7 @@
box-sizing: content-box !important; box-sizing: content-box !important;
} }
.shaka-play-button:hover { .shaka-play-button-container .shaka-play-button:hover {
background-color: rgba(35, 35, 35, 0.9) !important; background-color: rgba(35, 35, 35, 0.9) !important;
} }
@ -227,7 +230,7 @@
} }
@media (max-width: 768px) { @media (max-width: 768px) {
.shaka-play-button { .shaka-play-button-container .shaka-play-button {
padding: 1em !important; padding: 1em !important;
} }

View File

@ -53,7 +53,10 @@
var nativeStartTime = unscaledStartTime / timescale; var nativeStartTime = unscaledStartTime / timescale;
var nativeEndTime = (unscaledStartTime + subsegmentDuration) / timescale; var nativeEndTime = (unscaledStartTime + subsegmentDuration) / timescale;
var uris = [uri + '&startTimeMs=' + Math.round((nativeStartTime + timestampOffset) * 1000) + '&sq=' + (i + 1)]; // NOTE: must be `let` (block-scoped). With `var` the closure below
// captures the function-scoped binding, so every SegmentReference would
// return the LAST segment's URL (wrong startTimeMs/sq -> SABR serves no media).
let uris = [uri + '&startTimeMs=' + Math.round((nativeStartTime + timestampOffset) * 1000) + '&sq=' + (i + 1)];
references.push( references.push(
new shaka.media.SegmentReference( new shaka.media.SegmentReference(

View File

@ -125,7 +125,10 @@
var currentOffset = segmentOffset + tuple.relativeOffset; var currentOffset = segmentOffset + tuple.relativeOffset;
if (lastTime != null) { if (lastTime != null) {
var uris1 = [uri + '&startTimeMs=' + Math.round((lastTime + timestampOffset) * 1000) + '&sq=' + (sq++)]; // NOTE: must be `let` (block-scoped). With `var` the closure below
// captures the function-scoped binding, so every SegmentReference would
// return the LAST segment's URL (wrong startTimeMs/sq -> SABR serves no media).
let uris1 = [uri + '&startTimeMs=' + Math.round((lastTime + timestampOffset) * 1000) + '&sq=' + (sq++)];
references.push( references.push(
new shaka.media.SegmentReference( new shaka.media.SegmentReference(
lastTime + timestampOffset, lastTime + timestampOffset,