@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.cjs
CHANGED
|
@@ -3934,22 +3934,6 @@ function stabilizeLiveLagMs(previous, next) {
|
|
|
3934
3934
|
function isCaptionLocale(value) {
|
|
3935
3935
|
return CAPTION_LOCALES.includes(value);
|
|
3936
3936
|
}
|
|
3937
|
-
function isLivePlaylistSrc(src) {
|
|
3938
|
-
return /\/live\//i.test(src);
|
|
3939
|
-
}
|
|
3940
|
-
function zeroAnchorCaptionCues(cues) {
|
|
3941
|
-
if (cues.length === 0) return cues;
|
|
3942
|
-
let origin = Number.POSITIVE_INFINITY;
|
|
3943
|
-
for (const cue of cues) {
|
|
3944
|
-
if (Number.isFinite(cue.start) && cue.start < origin) origin = cue.start;
|
|
3945
|
-
}
|
|
3946
|
-
if (!Number.isFinite(origin) || origin <= 0) return cues;
|
|
3947
|
-
return cues.map((cue) => ({
|
|
3948
|
-
...cue,
|
|
3949
|
-
start: Math.max(0, cue.start - origin),
|
|
3950
|
-
end: Math.max(0, cue.end - origin)
|
|
3951
|
-
}));
|
|
3952
|
-
}
|
|
3953
3937
|
function captionsVttUrlFromPlayback(src, locale) {
|
|
3954
3938
|
const trimmed = src.trim();
|
|
3955
3939
|
if (!trimmed) return null;
|
|
@@ -4363,32 +4347,6 @@ function syncNativeCaptionCue(video, track, text, holdSeconds = NATIVE_CAPTION_H
|
|
|
4363
4347
|
const hold = Number.isFinite(holdSeconds) ? Math.max(0.2, holdSeconds) : NATIVE_CAPTION_HOLD_S;
|
|
4364
4348
|
track.addCue(new VTTCue(start, start + hold, trimmed));
|
|
4365
4349
|
}
|
|
4366
|
-
function zeroAnchorNativeTrackCues(track) {
|
|
4367
|
-
const list = track.cues;
|
|
4368
|
-
if (!list || list.length === 0) return;
|
|
4369
|
-
let origin = Number.POSITIVE_INFINITY;
|
|
4370
|
-
for (let index = 0; index < list.length; index += 1) {
|
|
4371
|
-
const cue = list[index];
|
|
4372
|
-
if (cue && Number.isFinite(cue.startTime) && cue.startTime < origin) {
|
|
4373
|
-
origin = cue.startTime;
|
|
4374
|
-
}
|
|
4375
|
-
}
|
|
4376
|
-
if (!Number.isFinite(origin) || origin <= 0) return;
|
|
4377
|
-
const next = [];
|
|
4378
|
-
for (let index = 0; index < list.length; index += 1) {
|
|
4379
|
-
const cue = list[index];
|
|
4380
|
-
if (!(cue instanceof VTTCue)) continue;
|
|
4381
|
-
next.push(
|
|
4382
|
-
new VTTCue(
|
|
4383
|
-
Math.max(0, cue.startTime - origin),
|
|
4384
|
-
Math.max(0, cue.endTime - origin),
|
|
4385
|
-
cue.text
|
|
4386
|
-
)
|
|
4387
|
-
);
|
|
4388
|
-
}
|
|
4389
|
-
clearNativeCaptionCues(track);
|
|
4390
|
-
for (const cue of next) track.addCue(cue);
|
|
4391
|
-
}
|
|
4392
4350
|
function listenTextTracksChange(tracks, onChange) {
|
|
4393
4351
|
if (typeof tracks.addEventListener === "function") {
|
|
4394
4352
|
tracks.addEventListener("change", onChange);
|
|
@@ -4670,9 +4628,6 @@ function VideoPlayer({
|
|
|
4670
4628
|
function onSidecarTrackLoad(event) {
|
|
4671
4629
|
const track = event.currentTarget.track;
|
|
4672
4630
|
if (!track) return;
|
|
4673
|
-
if (isLivePlaylistSrc(src)) {
|
|
4674
|
-
zeroAnchorNativeTrackCues(track);
|
|
4675
|
-
}
|
|
4676
4631
|
const video = videoRef.current;
|
|
4677
4632
|
if (video) {
|
|
4678
4633
|
applyNativeTrackModes(
|
|
@@ -4772,8 +4727,7 @@ function VideoPlayer({
|
|
|
4772
4727
|
return;
|
|
4773
4728
|
}
|
|
4774
4729
|
const cues = await loadCaptionVtt(url);
|
|
4775
|
-
|
|
4776
|
-
if (!cancelled) setCaptionCues(next);
|
|
4730
|
+
if (!cancelled) setCaptionCues(cues);
|
|
4777
4731
|
};
|
|
4778
4732
|
void load();
|
|
4779
4733
|
if (!liveCaptionsBaseUrl) return;
|