This commit is contained in:
ct
2025-06-15 08:27:17 +08:00
parent f686de8f29
commit 361f630293
8 changed files with 215 additions and 72 deletions

View File

@@ -38,16 +38,40 @@ const VideoPreview = ({
// Refs
layerRef,
}) => {
// Function to determine which image source to use for videos
const getImageSource = (element) => {
// Check if this video should be playing right now
const isVideoActive = videoStates[element.id] && isPlaying;
// Use video if it's ready and currently active, otherwise use poster
if (isVideoActive && element.videoElement && element.isVideoReady) {
return element.videoElement;
} else if (element.posterImage && element.isVideoPoster) {
return element.posterImage;
}
// Fallback - no image ready yet
return null;
};
return (
<div>
<div>isPlaying: {isPlaying ? 'true' : 'false'}</div>
<Stage width={dimensions.width} height={dimensions.height} className="">
<Layer ref={layerRef}>
{activeElements.map((element) => {
if (element.type === 'video' && videoElements[element.id]) {
if (element.type === 'video') {
const imageSource = getImageSource(element);
if (!imageSource) {
return null; // Don't render if no source is ready
}
return (
<Image
key={element.id}
image={videoElements[element.id]}
image={imageSource}
x={element.x}
y={element.y}
width={element.width}