jbilcke-hf's picture
jbilcke-hf HF staff
Modifying AiTube to support Stories Factory use cases
6215321
raw
history blame
No virus
915 Bytes
import React, { useEffect, useRef } from 'react';
export function BasicVideo({
className = "",
src,
playbackSpeed = 1.0,
playsInline = true,
muted = true,
autoPlay = true,
loop = true,
}: {
className?: string
src?: string
playbackSpeed?: number
playsInline?: boolean
muted?: boolean
autoPlay?: boolean
loop?: boolean
}) {
const videoRef = useRef<HTMLVideoElement>(null)
// Setup and handle changing playback rate and video source
useEffect(() => {
if (videoRef.current) {
videoRef.current.playbackRate = playbackSpeed;
}
}, [videoRef.current, playbackSpeed]);
// Handle UI case for empty playlists
if (!src || typeof src !== "string") {
return <></>
}
return (
<video
ref={videoRef}
className={className}
playsInline={playsInline}
muted={muted}
autoPlay={autoPlay}
loop={loop}
src={src}
/>
);
};