import React from 'react'; import { useSelector } from 'react-redux'; import { IReduxState } from '../../../app/types'; import { VIDEO_SOURCE_TYPES } from '../../constants'; import { getVideoEmbedUrl, getVideoSourceType, isVideoPlaying } from '../../functions'; interface IProps { /** * The participant ID (video URL or YouTube ID). */ participantId: string; } /** * Component that renders a shared video tile in the filmstrip. * Displays the embedded video player inside the filmstrip thumbnail. * * @param {IProps} props - The component props. * @returns {React.ReactElement | null} */ const SharedVideoTile: React.FC = ({ participantId }) => { const { videoUrl } = useSelector( (state: IReduxState) => state['features/shared-video'] ); const isShared = useSelector((state: IReduxState) => isVideoPlaying(state)); if (!isShared || participantId !== videoUrl) { return null; } const sourceType = getVideoSourceType(videoUrl ?? ''); const renderPlayer = () => { if (!videoUrl) { return null; } if (sourceType === VIDEO_SOURCE_TYPES.YOUTUBE) { // videoUrl is a YouTube ID (not a full URL) for YouTube videos const youtubeId = videoUrl.match(/^https?:\/\//) ? null : videoUrl; const embedId = youtubeId ?? videoUrl; return (