feat: enhance stream URL handling and add initial offset support in VideoPlayer

This commit is contained in:
2026-03-11 19:51:51 +01:00
parent c9aa36bb5f
commit 4789dca679
5 changed files with 47 additions and 13 deletions

View File

@@ -4,10 +4,12 @@ interface VideoPlayerProps {
src?: string;
poster?: string;
className?: string;
/** Seek to this many seconds after metadata loads (broadcast sync on refresh). */
initialOffset?: number;
}
const VideoPlayer = forwardRef<HTMLVideoElement, VideoPlayerProps>(
({ src, poster, className }, ref) => {
({ src, poster, className, initialOffset }, ref) => {
return (
<div className={`relative h-full w-full bg-black ${className ?? ""}`}>
<video
@@ -16,6 +18,11 @@ const VideoPlayer = forwardRef<HTMLVideoElement, VideoPlayerProps>(
poster={poster}
autoPlay
playsInline
onLoadedMetadata={(e) => {
if (initialOffset && initialOffset > 0) {
e.currentTarget.currentTime = initialOffset;
}
}}
className="h-full w-full object-contain"
/>
</div>