@flapsdk/vault-runtime 0.1.32 → 0.1.33
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/{chunk-F6QSV3Y7.js → chunk-SH35MEPP.js} +487 -33
- package/chunk-SH35MEPP.js.map +1 -0
- package/package.json +2 -2
- package/runtime-contract.json +1 -1
- package/sdk.js +2 -2
- package/ui.js +1 -1
- package/chunk-F6QSV3Y7.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { shortenAddress, isValidAddress, ZERO_ADDRESS } from './chunk-B4WKI3EW.js';
|
|
2
2
|
import { isIpfsImageCid, resolveIpfsImageUrls, resolveIpfsImageUrl } from './chunk-SAG36LUR.js';
|
|
3
3
|
import { getTaxVaultHostChainConfig } from './chunk-FUOBTZMQ.js';
|
|
4
|
-
import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, X, ShieldCheck, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
|
|
4
|
+
import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, X, ShieldCheck, Play, Pause, VolumeX, Volume2, Maximize, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import * as React5 from 'react';
|
|
@@ -622,6 +622,226 @@ function VaultBanner({ title, description, badges, meta, action, icon, className
|
|
|
622
622
|
);
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
+
// src/ui/tsTimeline.ts
|
|
626
|
+
var PACKET_SIZE = 188;
|
|
627
|
+
var CLOCK_WRAP = 2 ** 33;
|
|
628
|
+
var wrapClock = (value) => (value % CLOCK_WRAP + CLOCK_WRAP) % CLOCK_WRAP;
|
|
629
|
+
function readTimestamp(bytes, offset) {
|
|
630
|
+
return (bytes[offset] & 14) * 2 ** 29 + bytes[offset + 1] * 2 ** 22 + (bytes[offset + 2] & 254) * 2 ** 14 + bytes[offset + 3] * 128 + (bytes[offset + 4] >> 1);
|
|
631
|
+
}
|
|
632
|
+
function writeTimestamp(bytes, offset, value) {
|
|
633
|
+
const clock2 = wrapClock(value);
|
|
634
|
+
bytes[offset] = bytes[offset] & 241 | Math.floor(clock2 / 2 ** 29) & 14;
|
|
635
|
+
bytes[offset + 1] = Math.floor(clock2 / 2 ** 22) & 255;
|
|
636
|
+
bytes[offset + 2] = Math.floor(clock2 / 2 ** 14) & 254 | 1;
|
|
637
|
+
bytes[offset + 3] = Math.floor(clock2 / 128) & 255;
|
|
638
|
+
bytes[offset + 4] = clock2 % 128 << 1 | 1;
|
|
639
|
+
}
|
|
640
|
+
var TsTimeline = class {
|
|
641
|
+
constructor(startMs) {
|
|
642
|
+
this.startMs = startMs;
|
|
643
|
+
this.pending = new Uint8Array(0);
|
|
644
|
+
this.shift = null;
|
|
645
|
+
this.held = [];
|
|
646
|
+
this.headers = /* @__PURE__ */ new Map();
|
|
647
|
+
}
|
|
648
|
+
push(chunk, final = false) {
|
|
649
|
+
const combined = new Uint8Array(this.pending.length + chunk.length);
|
|
650
|
+
combined.set(this.pending);
|
|
651
|
+
combined.set(chunk, this.pending.length);
|
|
652
|
+
const complete = combined.length - combined.length % PACKET_SIZE;
|
|
653
|
+
for (let offset = 0; offset < complete; offset += PACKET_SIZE) {
|
|
654
|
+
const packet = combined.slice(offset, offset + PACKET_SIZE);
|
|
655
|
+
if (packet[0] !== 71 || packet[1] & 128 || packet[3] & 192) throw new Error("Invalid MPEG-TS packet");
|
|
656
|
+
this.held.push(packet);
|
|
657
|
+
const pid = (packet[1] & 31) << 8 | packet[2];
|
|
658
|
+
const control = packet[3] >> 4 & 3;
|
|
659
|
+
let payload = 4;
|
|
660
|
+
if (control & 2) {
|
|
661
|
+
payload += 1 + packet[4];
|
|
662
|
+
if (payload > PACKET_SIZE) throw new Error("Invalid adaptation field");
|
|
663
|
+
}
|
|
664
|
+
if (!(control & 1) || payload === PACKET_SIZE) continue;
|
|
665
|
+
if (packet[1] & 64) {
|
|
666
|
+
if (this.headers.has(pid)) throw new Error("Incomplete PES header");
|
|
667
|
+
this.headers.set(pid, { bytes: [], length: 6 });
|
|
668
|
+
}
|
|
669
|
+
const header = this.headers.get(pid);
|
|
670
|
+
if (!header) continue;
|
|
671
|
+
for (let index = payload; index < PACKET_SIZE && header.bytes.length < header.length; index++) {
|
|
672
|
+
header.bytes.push({ packet, offset: index });
|
|
673
|
+
if (header.bytes.length === 6) {
|
|
674
|
+
const bytes = Uint8Array.from(header.bytes, ({ packet: packet2, offset: offset2 }) => packet2[offset2]);
|
|
675
|
+
const stream = bytes[3];
|
|
676
|
+
if (bytes[0] !== 0 || bytes[1] !== 0 || bytes[2] !== 1 || !(stream >= 192 && stream <= 239) && stream !== 189) {
|
|
677
|
+
this.headers.delete(pid);
|
|
678
|
+
break;
|
|
679
|
+
}
|
|
680
|
+
header.length = 9;
|
|
681
|
+
}
|
|
682
|
+
if (header.bytes.length === 9) {
|
|
683
|
+
const flags = header.bytes[7].packet[header.bytes[7].offset] >> 6;
|
|
684
|
+
header.length = flags === 3 ? 19 : flags === 2 ? 14 : 9;
|
|
685
|
+
if (header.bytes[8].packet[header.bytes[8].offset] < header.length - 9) throw new Error("Invalid PES timestamp header");
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (this.headers.has(pid) && header.bytes.length === header.length) {
|
|
689
|
+
if (header.length > 9) {
|
|
690
|
+
const bytes = Uint8Array.from(header.bytes, ({ packet: packet2, offset: offset2 }) => packet2[offset2]);
|
|
691
|
+
if (this.shift === null) this.shift = this.startMs * 90 - readTimestamp(bytes, header.length === 19 ? 14 : 9);
|
|
692
|
+
writeTimestamp(bytes, 9, readTimestamp(bytes, 9) + this.shift);
|
|
693
|
+
if (header.length === 19) writeTimestamp(bytes, 14, readTimestamp(bytes, 14) + this.shift);
|
|
694
|
+
header.bytes.forEach(({ packet: packet2, offset: offset2 }, index) => {
|
|
695
|
+
packet2[offset2] = bytes[index];
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
this.headers.delete(pid);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
this.pending = combined.slice(complete);
|
|
702
|
+
if (this.held.length > 4096 && (this.shift === null || this.headers.size)) throw new Error("Missing MPEG-TS timestamps");
|
|
703
|
+
if (final && (this.pending.length || this.headers.size || this.shift === null)) throw new Error("Incomplete MPEG-TS clip");
|
|
704
|
+
if (this.shift === null || this.headers.size) return new Uint8Array(0);
|
|
705
|
+
const output = new Uint8Array(this.held.length * PACKET_SIZE);
|
|
706
|
+
this.held.forEach((packet, index) => {
|
|
707
|
+
if (packet[3] & 32 && packet[4] >= 7 && packet[5] & 16) {
|
|
708
|
+
const base = packet[6] * 2 ** 25 + packet[7] * 2 ** 17 + packet[8] * 512 + packet[9] * 2 + (packet[10] >> 7);
|
|
709
|
+
const clock2 = wrapClock(base + this.shift);
|
|
710
|
+
packet[6] = Math.floor(clock2 / 2 ** 25) & 255;
|
|
711
|
+
packet[7] = Math.floor(clock2 / 2 ** 17) & 255;
|
|
712
|
+
packet[8] = Math.floor(clock2 / 512) & 255;
|
|
713
|
+
packet[9] = Math.floor(clock2 / 2) & 255;
|
|
714
|
+
packet[10] = packet[10] & 127 | clock2 % 2 << 7;
|
|
715
|
+
}
|
|
716
|
+
output.set(packet, index * PACKET_SIZE);
|
|
717
|
+
});
|
|
718
|
+
this.held = [];
|
|
719
|
+
return output;
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
// src/ui/continuousVideoLoader.ts
|
|
724
|
+
function createContinuousVideoLoader(source, video, fetchImpl = fetch) {
|
|
725
|
+
return class {
|
|
726
|
+
constructor() {
|
|
727
|
+
this._status = 0;
|
|
728
|
+
this._needStash = false;
|
|
729
|
+
this.type = "flap-continuous-video";
|
|
730
|
+
this.onContentLengthKnown = (_length) => {
|
|
731
|
+
};
|
|
732
|
+
this.onURLRedirect = (_url) => {
|
|
733
|
+
};
|
|
734
|
+
this.onDataArrival = (_chunk, _byteStart, _receivedLength) => {
|
|
735
|
+
};
|
|
736
|
+
this.onError = (_type, _error) => {
|
|
737
|
+
};
|
|
738
|
+
this.onComplete = (_from, _to) => {
|
|
739
|
+
};
|
|
740
|
+
this.abortController = null;
|
|
741
|
+
}
|
|
742
|
+
get status() {
|
|
743
|
+
return this._status;
|
|
744
|
+
}
|
|
745
|
+
get needStashBuffer() {
|
|
746
|
+
return this._needStash;
|
|
747
|
+
}
|
|
748
|
+
isWorking() {
|
|
749
|
+
return this._status === 1 || this._status === 2;
|
|
750
|
+
}
|
|
751
|
+
destroy() {
|
|
752
|
+
this.abort();
|
|
753
|
+
}
|
|
754
|
+
abort() {
|
|
755
|
+
this.abortController?.abort();
|
|
756
|
+
this.abortController = null;
|
|
757
|
+
this._status = 0;
|
|
758
|
+
}
|
|
759
|
+
open(_data, range) {
|
|
760
|
+
this.abort();
|
|
761
|
+
const controller = new AbortController();
|
|
762
|
+
this.abortController = controller;
|
|
763
|
+
this._status = 1;
|
|
764
|
+
if (range.from !== 0) {
|
|
765
|
+
this.fail(controller);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
void this.pump(controller);
|
|
769
|
+
}
|
|
770
|
+
fail(controller) {
|
|
771
|
+
if (controller.signal.aborted) return;
|
|
772
|
+
this._status = 3;
|
|
773
|
+
controller.abort();
|
|
774
|
+
this.onError("Exception", { code: -1, msg: "Could not load video clip." });
|
|
775
|
+
}
|
|
776
|
+
async waitUntil(predicate, signal) {
|
|
777
|
+
while (!predicate()) {
|
|
778
|
+
signal.throwIfAborted();
|
|
779
|
+
await new Promise((resolve, reject) => {
|
|
780
|
+
const cleanup = () => {
|
|
781
|
+
clearTimeout(timer);
|
|
782
|
+
video.removeEventListener("timeupdate", wake);
|
|
783
|
+
signal.removeEventListener("abort", abort);
|
|
784
|
+
};
|
|
785
|
+
const wake = () => {
|
|
786
|
+
cleanup();
|
|
787
|
+
resolve();
|
|
788
|
+
};
|
|
789
|
+
const abort = () => {
|
|
790
|
+
cleanup();
|
|
791
|
+
reject(signal.reason);
|
|
792
|
+
};
|
|
793
|
+
const timer = setTimeout(wake, 250);
|
|
794
|
+
video.addEventListener("timeupdate", wake, { once: true });
|
|
795
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
async pump(controller) {
|
|
800
|
+
const signal = controller.signal;
|
|
801
|
+
let byteStart = 0;
|
|
802
|
+
let expectedPts = source.startPtsMs;
|
|
803
|
+
try {
|
|
804
|
+
for (let index = source.startIndex; ; index++) {
|
|
805
|
+
const clip = await source.readClip(index, signal);
|
|
806
|
+
signal.throwIfAborted();
|
|
807
|
+
if (clip.index !== index || clip.startPtsMs !== expectedPts) throw new Error("Discontinuous clips");
|
|
808
|
+
expectedPts += BigInt(clip.durationMs);
|
|
809
|
+
const start = Number(clip.startPtsMs - source.startPtsMs) / 1e3;
|
|
810
|
+
await this.waitUntil(() => start <= Math.max(video.currentTime, source.resumeAt) + 24, signal);
|
|
811
|
+
const url = resolveIpfsImageUrl(clip.videoCid);
|
|
812
|
+
if (!url) throw new Error("Invalid clip CID");
|
|
813
|
+
const response = await fetchImpl(url, { signal, mode: "cors", credentials: "omit", referrerPolicy: "no-referrer", redirect: "error" });
|
|
814
|
+
if (!response.ok || !response.body) throw new Error("Clip unavailable");
|
|
815
|
+
const timeline = new TsTimeline(start * 1e3);
|
|
816
|
+
const reader = response.body.getReader();
|
|
817
|
+
try {
|
|
818
|
+
while (true) {
|
|
819
|
+
await this.waitUntil(() => !video.buffered.length || video.buffered.end(video.buffered.length - 1) <= Math.max(video.currentTime, source.resumeAt) + 32, signal);
|
|
820
|
+
const { done, value } = await reader.read();
|
|
821
|
+
signal.throwIfAborted();
|
|
822
|
+
const bytes = timeline.push(value ?? new Uint8Array(0), done).buffer;
|
|
823
|
+
if (bytes.byteLength === 0) {
|
|
824
|
+
if (done) break;
|
|
825
|
+
continue;
|
|
826
|
+
}
|
|
827
|
+
this._status = 2;
|
|
828
|
+
this.onDataArrival(bytes, byteStart, byteStart + bytes.byteLength);
|
|
829
|
+
byteStart += bytes.byteLength;
|
|
830
|
+
if (video.ended && source.playIntent()) void video.play().catch(() => void 0);
|
|
831
|
+
if (done) break;
|
|
832
|
+
}
|
|
833
|
+
} finally {
|
|
834
|
+
await reader.cancel().catch(() => void 0);
|
|
835
|
+
reader.releaseLock();
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
} catch {
|
|
839
|
+
this.fail(controller);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
|
|
625
845
|
// src/ui/videoSession.ts
|
|
626
846
|
function videoSessionSegments(clips) {
|
|
627
847
|
if (!Array.isArray(clips)) return null;
|
|
@@ -741,6 +961,81 @@ var VideoSessionController = class {
|
|
|
741
961
|
this.onState("error");
|
|
742
962
|
}
|
|
743
963
|
}
|
|
964
|
+
async updateContinuous(source, autoPlay = false, resumeAt = 0) {
|
|
965
|
+
const key = `continuous:${source.revision}`;
|
|
966
|
+
if (this.key === key) return;
|
|
967
|
+
this.key = key;
|
|
968
|
+
const generation = ++this.generation;
|
|
969
|
+
this.destroyPlayer();
|
|
970
|
+
this.onState("loading");
|
|
971
|
+
try {
|
|
972
|
+
const mpegts = await this.loadMpegts();
|
|
973
|
+
if (generation !== this.generation) return;
|
|
974
|
+
if (!mpegts.isSupported()) {
|
|
975
|
+
this.onState("unsupported");
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const player = mpegts.createPlayer({
|
|
979
|
+
type: "mse",
|
|
980
|
+
isLive: false,
|
|
981
|
+
cors: true,
|
|
982
|
+
withCredentials: false,
|
|
983
|
+
url: resolveIpfsImageUrl(source.firstVideoCid)
|
|
984
|
+
}, {
|
|
985
|
+
enableWorker: false,
|
|
986
|
+
enableWorkerForMSE: false,
|
|
987
|
+
accurateSeek: true,
|
|
988
|
+
lazyLoad: false,
|
|
989
|
+
autoCleanupSourceBuffer: true,
|
|
990
|
+
autoCleanupMaxBackwardDuration: 60,
|
|
991
|
+
autoCleanupMinBackwardDuration: 30,
|
|
992
|
+
customLoader: createContinuousVideoLoader(source, this.video),
|
|
993
|
+
referrerPolicy: "no-referrer"
|
|
994
|
+
});
|
|
995
|
+
if (generation !== this.generation) {
|
|
996
|
+
player.destroy();
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
this.player = player;
|
|
1000
|
+
let ready = false;
|
|
1001
|
+
const current = () => generation === this.generation && this.player === player;
|
|
1002
|
+
const onError = () => {
|
|
1003
|
+
if (current()) {
|
|
1004
|
+
this.destroyPlayer();
|
|
1005
|
+
this.onState("error");
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
const restore = () => {
|
|
1009
|
+
if (!current() || ready || this.video.readyState < 1) return;
|
|
1010
|
+
if (resumeAt > 0 && !Array.from({ length: this.video.buffered.length }, (_, i) => i).some((i) => resumeAt >= this.video.buffered.start(i) - 0.25 && resumeAt < this.video.buffered.end(i))) return;
|
|
1011
|
+
ready = true;
|
|
1012
|
+
try {
|
|
1013
|
+
if (resumeAt > 0) player.currentTime = resumeAt;
|
|
1014
|
+
this.onState("ready");
|
|
1015
|
+
if (autoPlay) player.play()?.catch(() => void 0);
|
|
1016
|
+
} catch {
|
|
1017
|
+
onError();
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
player.on(mpegts.Events.ERROR, onError);
|
|
1021
|
+
this.video.addEventListener("error", onError);
|
|
1022
|
+
this.video.addEventListener("loadedmetadata", restore);
|
|
1023
|
+
this.video.addEventListener("progress", restore);
|
|
1024
|
+
this.removeListeners = () => {
|
|
1025
|
+
player.off(mpegts.Events.ERROR, onError);
|
|
1026
|
+
this.video.removeEventListener("error", onError);
|
|
1027
|
+
this.video.removeEventListener("loadedmetadata", restore);
|
|
1028
|
+
this.video.removeEventListener("progress", restore);
|
|
1029
|
+
};
|
|
1030
|
+
player.attachMediaElement(this.video);
|
|
1031
|
+
player.load();
|
|
1032
|
+
} catch {
|
|
1033
|
+
if (generation === this.generation) {
|
|
1034
|
+
this.destroyPlayer();
|
|
1035
|
+
this.onState("error");
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
744
1039
|
dispose() {
|
|
745
1040
|
++this.generation;
|
|
746
1041
|
this.destroyPlayer();
|
|
@@ -762,13 +1057,14 @@ var VIDEO_WINDOW_SIZE = 4;
|
|
|
762
1057
|
var VIDEO_PICKER_PAGE_SIZE = 20;
|
|
763
1058
|
var VIDEO_SESSION_POLL_MS = 8e3;
|
|
764
1059
|
var MAX_CACHED_CLIPS = 128;
|
|
1060
|
+
var nextSessionId = 0;
|
|
765
1061
|
function resolveVideoClipIndex(index, length) {
|
|
766
1062
|
if (!Number.isSafeInteger(index) || !Number.isSafeInteger(length) || length < 0) throw new VideoSessionReadError("invalid", "Invalid video clip index.");
|
|
767
1063
|
return length === 0 ? null : Math.max(0, Math.min(length - 1, index < 0 ? length + index : index));
|
|
768
1064
|
}
|
|
769
|
-
function videoClipPosition(clips, timeSeconds) {
|
|
1065
|
+
function videoClipPosition(clips, timeSeconds, mediaStartPtsMs = clips[0]?.startPtsMs ?? 0n) {
|
|
770
1066
|
if (!clips.length) return null;
|
|
771
|
-
const elapsedMs = Math.max(0, Number.isFinite(timeSeconds) ? timeSeconds * 1e3 : 0);
|
|
1067
|
+
const elapsedMs = Math.max(0, Number.isFinite(timeSeconds) ? timeSeconds * 1e3 : 0) + Number(mediaStartPtsMs - clips[0].startPtsMs);
|
|
772
1068
|
let clip = clips[0];
|
|
773
1069
|
for (const candidate of clips) {
|
|
774
1070
|
if (Number(candidate.startPtsMs - clips[0].startPtsMs) <= elapsedMs) clip = candidate;
|
|
@@ -783,17 +1079,21 @@ var ConsumerVideoSession = class {
|
|
|
783
1079
|
this.emit = emit;
|
|
784
1080
|
this.cache = /* @__PURE__ */ new Map();
|
|
785
1081
|
this.generation = 0;
|
|
1082
|
+
this.selectionGeneration = 0;
|
|
786
1083
|
this.disposed = false;
|
|
787
1084
|
this.refreshing = false;
|
|
788
1085
|
this.advancing = false;
|
|
1086
|
+
this.waiters = /* @__PURE__ */ new Set();
|
|
789
1087
|
this.initialIndex = 0;
|
|
790
1088
|
this.started = false;
|
|
791
|
-
this.snapshot = { state: "loading", total: 0, start: 0, clips: [], revision: 0, resumeAt: 0, play: false, refreshFailed: false, preservePosition: false };
|
|
1089
|
+
this.snapshot = { sessionId: 0, state: "loading", total: 0, start: 0, clips: [], revision: 0, resumeAt: 0, play: false, refreshFailed: false, preservePosition: false, firstPtsMs: 0n, endPtsMs: 0n, mediaStartPtsMs: 0n, mediaStartIndex: 0, mediaVideoCid: "" };
|
|
1090
|
+
this.snapshot.sessionId = ++nextSessionId;
|
|
792
1091
|
}
|
|
793
1092
|
publish(value) {
|
|
794
1093
|
if (this.disposed) return;
|
|
795
1094
|
this.snapshot = { ...this.snapshot, ...value };
|
|
796
1095
|
this.emit(this.snapshot);
|
|
1096
|
+
for (const wake of this.waiters) wake();
|
|
797
1097
|
}
|
|
798
1098
|
async refresh(initialIndex, play = false) {
|
|
799
1099
|
if (this.disposed || this.refreshing) return;
|
|
@@ -806,7 +1106,24 @@ var ConsumerVideoSession = class {
|
|
|
806
1106
|
const previous = this.snapshot.total;
|
|
807
1107
|
const shrank = total < previous;
|
|
808
1108
|
if (shrank) this.cache.clear();
|
|
809
|
-
|
|
1109
|
+
let firstPtsMs = this.snapshot.firstPtsMs;
|
|
1110
|
+
let endPtsMs = this.snapshot.endPtsMs;
|
|
1111
|
+
if (total && (total !== previous || !this.started)) {
|
|
1112
|
+
const [first, last] = await Promise.all([
|
|
1113
|
+
this.reader.readSlice(0, 1),
|
|
1114
|
+
this.reader.readSlice(total - 1, 1)
|
|
1115
|
+
]);
|
|
1116
|
+
if (this.disposed) return;
|
|
1117
|
+
if (first.length !== 1 || last.length !== 1 || first[0].index !== 0 || last[0].index !== total - 1) {
|
|
1118
|
+
throw new VideoSessionReadError("invalid", "Incomplete video timeline.");
|
|
1119
|
+
}
|
|
1120
|
+
firstPtsMs = first[0].startPtsMs;
|
|
1121
|
+
endPtsMs = last[0].startPtsMs + BigInt(last[0].durationMs);
|
|
1122
|
+
if (endPtsMs <= firstPtsMs || endPtsMs - firstPtsMs > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
1123
|
+
throw new VideoSessionReadError("invalid", "Invalid video timeline.");
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
this.publish({ total, firstPtsMs, endPtsMs, refreshFailed: false });
|
|
810
1127
|
if (total === 0) {
|
|
811
1128
|
++this.generation;
|
|
812
1129
|
this.publish({ state: "empty", clips: [], start: 0 });
|
|
@@ -821,6 +1138,7 @@ var ConsumerVideoSession = class {
|
|
|
821
1138
|
}
|
|
822
1139
|
}
|
|
823
1140
|
async seek(index, resumeAt = 0, play = false) {
|
|
1141
|
+
++this.selectionGeneration;
|
|
824
1142
|
const generation = ++this.generation;
|
|
825
1143
|
this.advancing = false;
|
|
826
1144
|
try {
|
|
@@ -833,26 +1151,78 @@ var ConsumerVideoSession = class {
|
|
|
833
1151
|
this.publish({ state: "loading", start, clips: [], resumeAt: 0, preservePosition: false, revision: this.snapshot.revision + 1 });
|
|
834
1152
|
const clips = await this.readWindow(start);
|
|
835
1153
|
if (this.disposed || generation !== this.generation) return;
|
|
836
|
-
this.publish({ state: "ready", start, clips, resumeAt, play, refreshFailed: false, revision: this.snapshot.revision + 1 });
|
|
1154
|
+
this.publish({ state: "ready", start, clips, resumeAt, play, mediaStartPtsMs: clips[0].startPtsMs, mediaStartIndex: start, mediaVideoCid: clips[0].videoCid, refreshFailed: false, revision: this.snapshot.revision + 1 });
|
|
837
1155
|
} catch (error) {
|
|
838
1156
|
if (generation === this.generation) this.fail(error);
|
|
839
1157
|
}
|
|
840
1158
|
}
|
|
841
|
-
/** Roll
|
|
1159
|
+
/** Roll only the bounded metadata view; keep the current media stream alive. */
|
|
842
1160
|
async advance(index) {
|
|
843
|
-
if (this.disposed || this.advancing || this.snapshot.refreshFailed || this.snapshot.state !== "ready" || index < this.snapshot.start || this.snapshot.start + this.snapshot.clips.length >= this.snapshot.total) return;
|
|
1161
|
+
if (this.disposed || this.advancing || this.snapshot.refreshFailed || this.snapshot.state !== "ready" || index < this.snapshot.start || index >= this.snapshot.start + this.snapshot.clips.length || this.snapshot.start + this.snapshot.clips.length >= this.snapshot.total) return;
|
|
844
1162
|
const generation = this.generation;
|
|
845
1163
|
this.advancing = true;
|
|
846
1164
|
try {
|
|
847
1165
|
const clips = await this.readWindow(index);
|
|
848
1166
|
if (this.disposed || generation !== this.generation) return;
|
|
849
|
-
this.publish({ state: "ready", start: index, clips, preservePosition: true, refreshFailed: false
|
|
1167
|
+
this.publish({ state: "ready", start: index, clips, preservePosition: true, refreshFailed: false });
|
|
850
1168
|
} catch {
|
|
851
1169
|
if (generation === this.generation) this.publish({ refreshFailed: true });
|
|
852
1170
|
} finally {
|
|
853
1171
|
if (generation === this.generation) this.advancing = false;
|
|
854
1172
|
}
|
|
855
1173
|
}
|
|
1174
|
+
/** The media loader waits at the tail so newly generated clips continue the same stream. */
|
|
1175
|
+
async readClip(index, signal) {
|
|
1176
|
+
while (index >= this.snapshot.total) {
|
|
1177
|
+
signal.throwIfAborted();
|
|
1178
|
+
if (this.disposed) throw new DOMException("Session disposed", "AbortError");
|
|
1179
|
+
await new Promise((resolve, reject) => {
|
|
1180
|
+
const cleanup = () => {
|
|
1181
|
+
this.waiters.delete(wake);
|
|
1182
|
+
signal.removeEventListener("abort", abort);
|
|
1183
|
+
};
|
|
1184
|
+
const wake = () => {
|
|
1185
|
+
cleanup();
|
|
1186
|
+
resolve();
|
|
1187
|
+
};
|
|
1188
|
+
const abort = () => {
|
|
1189
|
+
cleanup();
|
|
1190
|
+
reject(signal.reason);
|
|
1191
|
+
};
|
|
1192
|
+
this.waiters.add(wake);
|
|
1193
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
signal.throwIfAborted();
|
|
1197
|
+
const cached = this.cache.get(index);
|
|
1198
|
+
const clip = cached ?? (await this.readWindow(index))[0];
|
|
1199
|
+
signal.throwIfAborted();
|
|
1200
|
+
if (!clip || this.disposed) throw new DOMException("Session changed", "AbortError");
|
|
1201
|
+
return clip;
|
|
1202
|
+
}
|
|
1203
|
+
async seekTime(seconds, play) {
|
|
1204
|
+
if (!Number.isFinite(seconds) || !this.snapshot.total) return;
|
|
1205
|
+
const generation = this.generation;
|
|
1206
|
+
const selection = ++this.selectionGeneration;
|
|
1207
|
+
try {
|
|
1208
|
+
const millis = Math.min(Number(this.snapshot.endPtsMs - this.snapshot.firstPtsMs), Math.max(0, seconds) * 1e3);
|
|
1209
|
+
const target = this.snapshot.firstPtsMs + BigInt(Math.round(millis));
|
|
1210
|
+
let low = 0, high = this.snapshot.total - 1;
|
|
1211
|
+
while (low < high) {
|
|
1212
|
+
const mid = Math.ceil((low + high) / 2);
|
|
1213
|
+
const [clip2] = await this.readWindow(mid);
|
|
1214
|
+
if (this.disposed || generation !== this.generation || selection !== this.selectionGeneration || !clip2) return;
|
|
1215
|
+
if (clip2.startPtsMs <= target) low = mid;
|
|
1216
|
+
else high = mid - 1;
|
|
1217
|
+
}
|
|
1218
|
+
const [clip] = await this.readWindow(low);
|
|
1219
|
+
if (this.disposed || generation !== this.generation || selection !== this.selectionGeneration || !clip) return;
|
|
1220
|
+
const offset = Math.max(0, Math.min(clip.durationMs - 1, Number(target - clip.startPtsMs))) / 1e3;
|
|
1221
|
+
await this.seek(low, offset, play);
|
|
1222
|
+
} catch {
|
|
1223
|
+
if (generation === this.generation && selection === this.selectionGeneration) this.publish({ refreshFailed: true });
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
856
1226
|
async readWindow(start) {
|
|
857
1227
|
const generation = this.generation;
|
|
858
1228
|
const end = Math.min(this.snapshot.total, start + VIDEO_WINDOW_SIZE);
|
|
@@ -888,12 +1258,22 @@ var ConsumerVideoSession = class {
|
|
|
888
1258
|
this.disposed = true;
|
|
889
1259
|
++this.generation;
|
|
890
1260
|
this.cache.clear();
|
|
1261
|
+
for (const wake of this.waiters) wake();
|
|
1262
|
+
this.waiters.clear();
|
|
891
1263
|
}
|
|
892
1264
|
};
|
|
893
1265
|
|
|
894
1266
|
// src/ui/videoPlayerMessages.ts
|
|
895
1267
|
var videoPlayerMessages = {
|
|
896
1268
|
en: {
|
|
1269
|
+
play: "Play",
|
|
1270
|
+
pause: "Pause",
|
|
1271
|
+
mute: "Mute",
|
|
1272
|
+
unmute: "Unmute",
|
|
1273
|
+
volume: "Volume",
|
|
1274
|
+
fullscreen: "Fullscreen",
|
|
1275
|
+
timeline: "Playback time",
|
|
1276
|
+
timelineSeek: "Video timeline",
|
|
897
1277
|
loading: "Loading video\u2026",
|
|
898
1278
|
buffering: "Buffering\u2026",
|
|
899
1279
|
previous: "Previous clip",
|
|
@@ -912,6 +1292,14 @@ var videoPlayerMessages = {
|
|
|
912
1292
|
go: "Go"
|
|
913
1293
|
},
|
|
914
1294
|
zh: {
|
|
1295
|
+
play: "\u64AD\u653E",
|
|
1296
|
+
pause: "\u6682\u505C",
|
|
1297
|
+
mute: "\u9759\u97F3",
|
|
1298
|
+
unmute: "\u53D6\u6D88\u9759\u97F3",
|
|
1299
|
+
volume: "\u97F3\u91CF",
|
|
1300
|
+
fullscreen: "\u5168\u5C4F",
|
|
1301
|
+
timeline: "\u7D2F\u8BA1\u64AD\u653E\u65F6\u95F4",
|
|
1302
|
+
timelineSeek: "\u89C6\u9891\u603B\u8FDB\u5EA6",
|
|
915
1303
|
loading: "\u6B63\u5728\u8F7D\u5165\u89C6\u9891\u2026",
|
|
916
1304
|
buffering: "\u6B63\u5728\u7F13\u51B2\u2026",
|
|
917
1305
|
previous: "\u4E0A\u4E00\u6BB5",
|
|
@@ -930,6 +1318,14 @@ var videoPlayerMessages = {
|
|
|
930
1318
|
go: "\u8DF3\u8F6C"
|
|
931
1319
|
},
|
|
932
1320
|
ko: {
|
|
1321
|
+
play: "\uC7AC\uC0DD",
|
|
1322
|
+
pause: "\uC77C\uC2DC \uC815\uC9C0",
|
|
1323
|
+
mute: "\uC74C\uC18C\uAC70",
|
|
1324
|
+
unmute: "\uC74C\uC18C\uAC70 \uD574\uC81C",
|
|
1325
|
+
volume: "\uC74C\uB7C9",
|
|
1326
|
+
fullscreen: "\uC804\uCCB4 \uD654\uBA74",
|
|
1327
|
+
timeline: "\uC7AC\uC0DD \uC2DC\uAC04",
|
|
1328
|
+
timelineSeek: "\uB3D9\uC601\uC0C1 \uC804\uCCB4 \uC9C4\uD589\uB960",
|
|
933
1329
|
loading: "\uB3D9\uC601\uC0C1 \uBD88\uB7EC\uC624\uB294 \uC911\u2026",
|
|
934
1330
|
buffering: "\uBC84\uD37C\uB9C1 \uC911\u2026",
|
|
935
1331
|
previous: "\uC774\uC804 \uD074\uB9BD",
|
|
@@ -950,7 +1346,7 @@ var videoPlayerMessages = {
|
|
|
950
1346
|
};
|
|
951
1347
|
|
|
952
1348
|
// src/ui/ConsumerVideoSessionPlayer.tsx
|
|
953
|
-
var initialSnapshot = { state: "loading", total: 0, start: 0, clips: [], revision: 0, resumeAt: 0, play: false, refreshFailed: false, preservePosition: false };
|
|
1349
|
+
var initialSnapshot = { sessionId: 0, state: "loading", total: 0, start: 0, clips: [], revision: 0, resumeAt: 0, play: false, refreshFailed: false, preservePosition: false, firstPtsMs: 0n, endPtsMs: 0n, mediaStartPtsMs: 0n, mediaStartIndex: 0, mediaVideoCid: "" };
|
|
954
1350
|
var clock = (seconds) => `${Math.floor(seconds / 60)}:${Math.floor(seconds % 60).toString().padStart(2, "0")}`;
|
|
955
1351
|
function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback = null, className, autoPlay = false, muted = false }) {
|
|
956
1352
|
const sdk = useFlapSdk();
|
|
@@ -960,17 +1356,25 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
960
1356
|
const sessionRef = React5.useRef(null);
|
|
961
1357
|
const controllerRef = React5.useRef(null);
|
|
962
1358
|
const videoRef = React5.useRef(null);
|
|
963
|
-
const
|
|
1359
|
+
const frameRef = React5.useRef(null);
|
|
964
1360
|
const playIntent = React5.useRef(autoPlay);
|
|
965
1361
|
const autoPlayRef = React5.useRef(autoPlay);
|
|
966
1362
|
autoPlayRef.current = autoPlay;
|
|
967
1363
|
const [snapshot, setSnapshot] = React5.useState(initialSnapshot);
|
|
968
1364
|
const [mediaState, setMediaState] = React5.useState("loading");
|
|
969
1365
|
const [time, setTime] = React5.useState(0);
|
|
1366
|
+
const [paused, setPaused] = React5.useState(true);
|
|
1367
|
+
const [isMuted, setIsMuted] = React5.useState(muted);
|
|
1368
|
+
const [volume, setVolume] = React5.useState(1);
|
|
1369
|
+
React5.useEffect(() => {
|
|
1370
|
+
setIsMuted(muted);
|
|
1371
|
+
}, [muted]);
|
|
970
1372
|
const [buffering, setBuffering] = React5.useState(false);
|
|
971
1373
|
const [page, setPage] = React5.useState(0);
|
|
972
1374
|
const [jump, setJump] = React5.useState("");
|
|
973
|
-
const position = videoClipPosition(snapshot.clips, time);
|
|
1375
|
+
const position = videoClipPosition(snapshot.clips, time, snapshot.mediaStartPtsMs);
|
|
1376
|
+
const duration = Number(snapshot.endPtsMs - snapshot.firstPtsMs) / 1e3;
|
|
1377
|
+
const globalTime = Math.max(0, Math.min(duration, Number(snapshot.mediaStartPtsMs - snapshot.firstPtsMs) / 1e3 + time));
|
|
974
1378
|
const activeIndex = position?.index ?? snapshot.start;
|
|
975
1379
|
const strings = videoPlayerMessages[sdk.i18n.locale.split("-")[0]] ?? videoPlayerMessages.en;
|
|
976
1380
|
const text = (key, params) => sdk.i18n.t(`runtime.video.${key}`, strings[key], params);
|
|
@@ -986,6 +1390,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
986
1390
|
}, VIDEO_SESSION_POLL_MS);
|
|
987
1391
|
return () => {
|
|
988
1392
|
window.clearInterval(timer);
|
|
1393
|
+
void controllerRef.current?.update([]);
|
|
989
1394
|
session.dispose();
|
|
990
1395
|
sessionRef.current = null;
|
|
991
1396
|
};
|
|
@@ -1000,33 +1405,39 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1000
1405
|
};
|
|
1001
1406
|
}, []);
|
|
1002
1407
|
React5.useEffect(() => {
|
|
1003
|
-
const
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
play = !video.paused || video.ended && playIntent.current;
|
|
1408
|
+
const controller = controllerRef.current;
|
|
1409
|
+
const session = sessionRef.current;
|
|
1410
|
+
if (!controller || !session) return;
|
|
1411
|
+
if (snapshot.state !== "ready") {
|
|
1412
|
+
if (!snapshot.clips.length) void controller.update([]);
|
|
1413
|
+
return;
|
|
1010
1414
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1415
|
+
setTime(snapshot.resumeAt);
|
|
1416
|
+
void controller.updateContinuous({
|
|
1417
|
+
revision: snapshot.revision,
|
|
1418
|
+
startIndex: snapshot.mediaStartIndex,
|
|
1419
|
+
startPtsMs: snapshot.mediaStartPtsMs,
|
|
1420
|
+
firstVideoCid: snapshot.mediaVideoCid,
|
|
1421
|
+
resumeAt: snapshot.resumeAt,
|
|
1422
|
+
readClip: (index, signal) => session.readClip(index, signal),
|
|
1423
|
+
playIntent: () => playIntent.current
|
|
1424
|
+
}, snapshot.play, snapshot.resumeAt);
|
|
1425
|
+
}, [snapshot.sessionId, snapshot.revision, snapshot.state]);
|
|
1015
1426
|
React5.useEffect(() => {
|
|
1016
1427
|
setPage(Math.floor(activeIndex / VIDEO_PICKER_PAGE_SIZE));
|
|
1017
1428
|
}, [activeIndex]);
|
|
1018
1429
|
const advance = () => {
|
|
1019
1430
|
const video = videoRef.current;
|
|
1020
|
-
const current = videoClipPosition(snapshot.clips, video?.currentTime ?? 0);
|
|
1431
|
+
const current = videoClipPosition(snapshot.clips, video?.currentTime ?? 0, snapshot.mediaStartPtsMs);
|
|
1021
1432
|
if (video && current && (current.index >= snapshot.start + snapshot.clips.length - 2 || video.ended)) {
|
|
1022
1433
|
void sessionRef.current?.advance(current.index);
|
|
1023
1434
|
}
|
|
1024
1435
|
};
|
|
1025
1436
|
React5.useEffect(() => {
|
|
1026
1437
|
const video = videoRef.current;
|
|
1027
|
-
const current = videoClipPosition(snapshot.clips, video?.currentTime ?? 0);
|
|
1438
|
+
const current = videoClipPosition(snapshot.clips, video?.currentTime ?? 0, snapshot.mediaStartPtsMs);
|
|
1028
1439
|
if (video && current && (current.index >= snapshot.start + snapshot.clips.length - 2 || video.ended)) void sessionRef.current?.advance(current.index);
|
|
1029
|
-
}, [snapshot.total, snapshot.start, snapshot.clips]);
|
|
1440
|
+
}, [snapshot.total, snapshot.start, snapshot.clips, snapshot.mediaStartPtsMs]);
|
|
1030
1441
|
function seek(index) {
|
|
1031
1442
|
const video = videoRef.current;
|
|
1032
1443
|
const play = video ? !video.paused || video.ended && playIntent.current : playIntent.current;
|
|
@@ -1044,6 +1455,8 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1044
1455
|
"data-flap-video-consumer": consumer,
|
|
1045
1456
|
"data-flap-video-window-start": snapshot.start,
|
|
1046
1457
|
"data-flap-video-window-size": snapshot.clips.length,
|
|
1458
|
+
"data-flap-video-global-time": globalTime,
|
|
1459
|
+
"data-flap-video-media-revision": snapshot.revision,
|
|
1047
1460
|
onKeyDown: (event) => {
|
|
1048
1461
|
if (event.ctrlKey || event.altKey || event.metaKey || /^(INPUT|TEXTAREA|SELECT|BUTTON)$/.test(event.target.tagName)) return;
|
|
1049
1462
|
const video = videoRef.current;
|
|
@@ -1067,17 +1480,17 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1067
1480
|
}
|
|
1068
1481
|
}
|
|
1069
1482
|
},
|
|
1070
|
-
/* @__PURE__ */ React5.createElement("div", { className: "relative overflow-hidden rounded-lg border border-[#303236] bg-black" }, /* @__PURE__ */ React5.createElement(
|
|
1483
|
+
/* @__PURE__ */ React5.createElement("div", { ref: frameRef, className: "relative overflow-hidden rounded-lg border border-[#303236] bg-black [&:fullscreen]:flex [&:fullscreen]:flex-col [&:fullscreen]:justify-center [&:fullscreen>video]:h-0 [&:fullscreen>video]:min-h-0 [&:fullscreen>video]:flex-1 [&:fullscreen>video]:aspect-auto" }, /* @__PURE__ */ React5.createElement(
|
|
1071
1484
|
"video",
|
|
1072
1485
|
{
|
|
1073
1486
|
ref: videoRef,
|
|
1074
1487
|
"aria-label": label,
|
|
1075
|
-
controls: true,
|
|
1076
1488
|
playsInline: true,
|
|
1077
1489
|
disablePictureInPicture: true,
|
|
1078
1490
|
disableRemotePlayback: true,
|
|
1079
1491
|
preload: "metadata",
|
|
1080
|
-
muted,
|
|
1492
|
+
muted: isMuted,
|
|
1493
|
+
tabIndex: 0,
|
|
1081
1494
|
className: showVideo ? "block aspect-video w-full object-contain" : "hidden",
|
|
1082
1495
|
onTimeUpdate: () => {
|
|
1083
1496
|
setTime(videoRef.current?.currentTime ?? 0);
|
|
@@ -1085,17 +1498,58 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1085
1498
|
},
|
|
1086
1499
|
onPlay: () => {
|
|
1087
1500
|
playIntent.current = true;
|
|
1501
|
+
setPaused(false);
|
|
1088
1502
|
},
|
|
1089
1503
|
onPause: () => {
|
|
1504
|
+
setPaused(true);
|
|
1090
1505
|
if (!videoRef.current?.ended && mediaState === "ready") playIntent.current = false;
|
|
1091
1506
|
},
|
|
1507
|
+
onVolumeChange: () => {
|
|
1508
|
+
if (videoRef.current) {
|
|
1509
|
+
setIsMuted(videoRef.current.muted);
|
|
1510
|
+
setVolume(videoRef.current.volume);
|
|
1511
|
+
}
|
|
1512
|
+
},
|
|
1092
1513
|
onEnded: () => advance(),
|
|
1093
1514
|
onWaiting: () => setBuffering(true),
|
|
1094
1515
|
onStalled: () => setBuffering(true),
|
|
1095
1516
|
onCanPlay: () => setBuffering(false),
|
|
1096
1517
|
onPlaying: () => setBuffering(false)
|
|
1097
1518
|
}
|
|
1098
|
-
), (state === "loading" || buffering && showVideo) && /* @__PURE__ */ React5.createElement("p", { className: "pointer-events-none absolute inset-x-0 top-3 text-center text-sm text-white", role: "status" }, text(state === "loading" ? "loading" : "buffering")), !showVideo && /* @__PURE__ */ React5.createElement("div", { className: "p-4" }, fallback)),
|
|
1519
|
+
), (state === "loading" || buffering && showVideo) && /* @__PURE__ */ React5.createElement("p", { className: "pointer-events-none absolute inset-x-0 top-3 text-center text-sm text-white", role: "status" }, text(state === "loading" ? "loading" : "buffering")), !showVideo && /* @__PURE__ */ React5.createElement("div", { className: "p-4" }, fallback), showVideo && snapshot.total > 0 && /* @__PURE__ */ React5.createElement("div", { className: "space-y-2 border-t border-[#303236] bg-black p-3" }, /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React5.createElement(Button, { type: "button", variant: "ghost", "aria-label": text(paused ? "play" : "pause"), onClick: () => {
|
|
1520
|
+
const video = videoRef.current;
|
|
1521
|
+
if (video) {
|
|
1522
|
+
if (video.paused) void video.play().catch(() => void 0);
|
|
1523
|
+
else video.pause();
|
|
1524
|
+
}
|
|
1525
|
+
} }, paused ? /* @__PURE__ */ React5.createElement(Play, { "aria-hidden": "true", className: "h-4 w-4" }) : /* @__PURE__ */ React5.createElement(Pause, { "aria-hidden": "true", className: "h-4 w-4" })), /* @__PURE__ */ React5.createElement("span", { className: "flex-1 text-xs text-white", "aria-label": text("timeline"), "data-flap-video-time": true }, clock(globalTime), " / ", clock(duration)), /* @__PURE__ */ React5.createElement(Button, { type: "button", variant: "ghost", "aria-label": text(isMuted ? "unmute" : "mute"), onClick: () => {
|
|
1526
|
+
if (videoRef.current) videoRef.current.muted = !videoRef.current.muted;
|
|
1527
|
+
} }, isMuted ? /* @__PURE__ */ React5.createElement(VolumeX, { "aria-hidden": "true", className: "h-4 w-4" }) : /* @__PURE__ */ React5.createElement(Volume2, { "aria-hidden": "true", className: "h-4 w-4" })), /* @__PURE__ */ React5.createElement("input", { type: "range", min: 0, max: 1, step: 0.05, value: isMuted ? 0 : volume, "aria-label": text("volume"), className: "w-16 accent-[#D0FF00]", onChange: (event) => {
|
|
1528
|
+
if (videoRef.current) {
|
|
1529
|
+
videoRef.current.volume = Number(event.target.value);
|
|
1530
|
+
videoRef.current.muted = Number(event.target.value) === 0;
|
|
1531
|
+
}
|
|
1532
|
+
} }), /* @__PURE__ */ React5.createElement(Button, { type: "button", variant: "ghost", "aria-label": text("fullscreen"), onClick: () => {
|
|
1533
|
+
if (document.fullscreenElement) void document.exitFullscreen().catch(() => void 0);
|
|
1534
|
+
else void frameRef.current?.requestFullscreen?.().catch(() => void 0);
|
|
1535
|
+
} }, /* @__PURE__ */ React5.createElement(Maximize, { "aria-hidden": "true", className: "h-4 w-4" }))), /* @__PURE__ */ React5.createElement(
|
|
1536
|
+
"input",
|
|
1537
|
+
{
|
|
1538
|
+
type: "range",
|
|
1539
|
+
min: 0,
|
|
1540
|
+
max: duration,
|
|
1541
|
+
step: 0.05,
|
|
1542
|
+
value: globalTime,
|
|
1543
|
+
disabled: state !== "ready",
|
|
1544
|
+
"aria-label": text("timelineSeek"),
|
|
1545
|
+
className: "block min-h-6 w-full accent-[#D0FF00]",
|
|
1546
|
+
onChange: (event) => {
|
|
1547
|
+
const video = videoRef.current;
|
|
1548
|
+
const play = video ? !video.paused || video.ended && playIntent.current : playIntent.current;
|
|
1549
|
+
void sessionRef.current?.seekTime(Number(event.target.value), play);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
))),
|
|
1099
1553
|
snapshot.total > 0 && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: "flex flex-wrap items-center justify-between gap-2 text-xs text-[#D4D4D4]" }, /* @__PURE__ */ React5.createElement("span", { role: "status" }, text("position", { index: activeIndex + 1, total: snapshot.total })), /* @__PURE__ */ React5.createElement("span", null, clock(position?.time ?? 0), " / ", clock(position?.duration ?? 0))), /* @__PURE__ */ React5.createElement(
|
|
1100
1554
|
"input",
|
|
1101
1555
|
{
|
|
@@ -1111,7 +1565,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1111
1565
|
const video = videoRef.current;
|
|
1112
1566
|
const clip = snapshot.clips.find((item) => item.index === activeIndex);
|
|
1113
1567
|
if (video && clip) {
|
|
1114
|
-
video.currentTime = Number(clip.startPtsMs - snapshot.
|
|
1568
|
+
video.currentTime = Number(clip.startPtsMs - snapshot.mediaStartPtsMs) / 1e3 + Number(event.target.value);
|
|
1115
1569
|
setTime(video.currentTime);
|
|
1116
1570
|
}
|
|
1117
1571
|
}
|
|
@@ -1180,5 +1634,5 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
|
|
|
1180
1634
|
}
|
|
1181
1635
|
|
|
1182
1636
|
export { AddressLink, Alert, BinanceImage, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, Input, IpfsBackground, IpfsImage, Metric, NftMetadataImage, ReviewedFrame, RuntimeContext, StatusBadge, TxButton, VaultBanner, VideoSessionPlayer, VideoSessionReadError, buttonVariants, createConsumerVideoSessionReader, readVideoSessionLength, readVideoSessionSlice, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext };
|
|
1183
|
-
//# sourceMappingURL=chunk-
|
|
1184
|
-
//# sourceMappingURL=chunk-
|
|
1637
|
+
//# sourceMappingURL=chunk-SH35MEPP.js.map
|
|
1638
|
+
//# sourceMappingURL=chunk-SH35MEPP.js.map
|