import { FC, useRef } from 'react'; import ReactPlayer from 'react-player/youtube'; import { LocalizeText, YoutubeVideoPlaybackStateEnum } from '../../../../api'; import { AutoGrid, AutoGridProps, LayoutGridItem, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; import { useFurnitureYoutubeWidget } from '../../../../hooks'; interface FurnitureYoutubeDisplayViewProps extends AutoGridProps { } export const FurnitureYoutubeDisplayView: FC<{}> = FurnitureYoutubeDisplayViewProps => { const { objectId = -1, videoId = null, videoStart = 0, videoEnd = 0, currentVideoState = null, selectedVideo = null, playlists = [], onClose = null, previous = null, next = null, pause = null, play = null, selectVideo = null } = useFurnitureYoutubeWidget(); const playerRef = useRef(null); const handlePlay = () => { if(objectId === -1) return; if(currentVideoState !== YoutubeVideoPlaybackStateEnum.PLAYING) play(); }; const handlePause = () => { if(objectId === -1) return; if(currentVideoState !== YoutubeVideoPlaybackStateEnum.PAUSED) pause(); }; if(objectId === -1) return null; const playing = (currentVideoState === null) ? true : (currentVideoState === YoutubeVideoPlaybackStateEnum.PLAYING); return (
{ (videoId && videoId.length > 0) && } { (!videoId || videoId.length === 0) &&
{ LocalizeText('widget.furni.video_viewer.no_videos') }
}
{ LocalizeText('widget.furni.video_viewer.playlists') }
{ playlists && playlists.map((entry, index) => { return ( selectVideo(entry.video) }> { entry.title } ); }) }
); };