@livo-tv/blocks 1.25.0 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3908,22 +3908,6 @@ function stabilizeLiveLagMs(previous, next) {
|
|
|
3908
3908
|
function isCaptionLocale(value) {
|
|
3909
3909
|
return CAPTION_LOCALES.includes(value);
|
|
3910
3910
|
}
|
|
3911
|
-
function isLivePlaylistSrc(src) {
|
|
3912
|
-
return /\/live\//i.test(src);
|
|
3913
|
-
}
|
|
3914
|
-
function zeroAnchorCaptionCues(cues) {
|
|
3915
|
-
if (cues.length === 0) return cues;
|
|
3916
|
-
let origin = Number.POSITIVE_INFINITY;
|
|
3917
|
-
for (const cue of cues) {
|
|
3918
|
-
if (Number.isFinite(cue.start) && cue.start < origin) origin = cue.start;
|
|
3919
|
-
}
|
|
3920
|
-
if (!Number.isFinite(origin) || origin <= 0) return cues;
|
|
3921
|
-
return cues.map((cue) => ({
|
|
3922
|
-
...cue,
|
|
3923
|
-
start: Math.max(0, cue.start - origin),
|
|
3924
|
-
end: Math.max(0, cue.end - origin)
|
|
3925
|
-
}));
|
|
3926
|
-
}
|
|
3927
3911
|
function captionsVttUrlFromPlayback(src, locale) {
|
|
3928
3912
|
const trimmed = src.trim();
|
|
3929
3913
|
if (!trimmed) return null;
|
|
@@ -4337,32 +4321,6 @@ function syncNativeCaptionCue(video, track, text, holdSeconds = NATIVE_CAPTION_H
|
|
|
4337
4321
|
const hold = Number.isFinite(holdSeconds) ? Math.max(0.2, holdSeconds) : NATIVE_CAPTION_HOLD_S;
|
|
4338
4322
|
track.addCue(new VTTCue(start, start + hold, trimmed));
|
|
4339
4323
|
}
|
|
4340
|
-
function zeroAnchorNativeTrackCues(track) {
|
|
4341
|
-
const list = track.cues;
|
|
4342
|
-
if (!list || list.length === 0) return;
|
|
4343
|
-
let origin = Number.POSITIVE_INFINITY;
|
|
4344
|
-
for (let index = 0; index < list.length; index += 1) {
|
|
4345
|
-
const cue = list[index];
|
|
4346
|
-
if (cue && Number.isFinite(cue.startTime) && cue.startTime < origin) {
|
|
4347
|
-
origin = cue.startTime;
|
|
4348
|
-
}
|
|
4349
|
-
}
|
|
4350
|
-
if (!Number.isFinite(origin) || origin <= 0) return;
|
|
4351
|
-
const next = [];
|
|
4352
|
-
for (let index = 0; index < list.length; index += 1) {
|
|
4353
|
-
const cue = list[index];
|
|
4354
|
-
if (!(cue instanceof VTTCue)) continue;
|
|
4355
|
-
next.push(
|
|
4356
|
-
new VTTCue(
|
|
4357
|
-
Math.max(0, cue.startTime - origin),
|
|
4358
|
-
Math.max(0, cue.endTime - origin),
|
|
4359
|
-
cue.text
|
|
4360
|
-
)
|
|
4361
|
-
);
|
|
4362
|
-
}
|
|
4363
|
-
clearNativeCaptionCues(track);
|
|
4364
|
-
for (const cue of next) track.addCue(cue);
|
|
4365
|
-
}
|
|
4366
4324
|
function listenTextTracksChange(tracks, onChange) {
|
|
4367
4325
|
if (typeof tracks.addEventListener === "function") {
|
|
4368
4326
|
tracks.addEventListener("change", onChange);
|
|
@@ -4644,9 +4602,6 @@ function VideoPlayer({
|
|
|
4644
4602
|
function onSidecarTrackLoad(event) {
|
|
4645
4603
|
const track = event.currentTarget.track;
|
|
4646
4604
|
if (!track) return;
|
|
4647
|
-
if (isLivePlaylistSrc(src)) {
|
|
4648
|
-
zeroAnchorNativeTrackCues(track);
|
|
4649
|
-
}
|
|
4650
4605
|
const video = videoRef.current;
|
|
4651
4606
|
if (video) {
|
|
4652
4607
|
applyNativeTrackModes(
|
|
@@ -4746,8 +4701,7 @@ function VideoPlayer({
|
|
|
4746
4701
|
return;
|
|
4747
4702
|
}
|
|
4748
4703
|
const cues = await loadCaptionVtt(url);
|
|
4749
|
-
|
|
4750
|
-
if (!cancelled) setCaptionCues(next);
|
|
4704
|
+
if (!cancelled) setCaptionCues(cues);
|
|
4751
4705
|
};
|
|
4752
4706
|
void load();
|
|
4753
4707
|
if (!liveCaptionsBaseUrl) return;
|