v3: added index default tab selection setting, fixed notification pages not loading, reduced invite token length, global player state survives page reloads, many visual fixes
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 44s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 44s
This commit is contained in:
@@ -129,6 +129,7 @@ interface MediaPlayerProps {
|
||||
mime?: string;
|
||||
poster?: string;
|
||||
autoplay?: boolean;
|
||||
startTime?: number;
|
||||
onPlayStateChange?: (playing: boolean) => void;
|
||||
onTimeUpdate?: (time: number, duration: number) => void;
|
||||
seekRef?: { current: ((t: number) => void) | null };
|
||||
@@ -142,6 +143,7 @@ export function MediaPlayer(
|
||||
mime,
|
||||
poster,
|
||||
autoplay,
|
||||
startTime,
|
||||
onPlayStateChange,
|
||||
onTimeUpdate,
|
||||
seekRef,
|
||||
@@ -209,6 +211,21 @@ export function MediaPlayer(
|
||||
|
||||
// ── Effects ──────────────────────────────────────────────────────────────────
|
||||
|
||||
// Resume to a restored offset once metadata (and thus seekability) is available.
|
||||
// Runs only on mount for the initial offset — later seeks go through seekTo.
|
||||
useEffect(() => {
|
||||
if (!startTime) return;
|
||||
const a = mediaRef.current!;
|
||||
const apply = () => {
|
||||
a.currentTime = startTime;
|
||||
setCurrent(startTime);
|
||||
};
|
||||
if (a.readyState >= 1) apply();
|
||||
else a.addEventListener("loadedmetadata", apply, { once: true });
|
||||
return () => a.removeEventListener("loadedmetadata", apply);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Autoplay on mount (e.g. triggered by play() in PlayerContext)
|
||||
useEffect(() => {
|
||||
if (!autoplay) return;
|
||||
|
||||
Reference in New Issue
Block a user