diff --git a/Tips/src/components/TipNotification.tsx b/Tips/src/components/TipNotification.tsx index 9c2a1965..63ba9eae 100644 --- a/Tips/src/components/TipNotification.tsx +++ b/Tips/src/components/TipNotification.tsx @@ -1,6 +1,6 @@ import React from "react" -import { useState } from "react" +import { useState, useRef } from "react" import { Icon, Typography, @@ -18,6 +18,7 @@ import { import classnames from "classnames" import { useTranslation } from "react-i18next" import ReactMarkdown from "react-markdown" +import ReactPlayer from "react-player" const useStyles = makeStyles((theme: Theme) => @@ -133,6 +134,110 @@ function LinkRenderer(props: any) { ); } +function VideoRenderer({ url }: { url: string }) { + if(url.match(/dailymotion\.com\/video\/([^_]+)/)) { + const getDailymotionEmbedURL = (url: string) => { + const videoId = url.match(/dailymotion\.com\/video\/([^_]+)/); + if (videoId) { + return `https://www.dailymotion.com/embed/video/${videoId[1]}`; + } + return null; + }; + const [embedUrl, setEmbedUrl] = useState(null); + React.useEffect(() => { + const embed = getDailymotionEmbedURL(url); + setEmbedUrl(embed); + }, [url]); + + if (embedUrl) { + return ( +
+ +
+ ); + } + } + else { + const [isVideo, setIsVideo] = useState(false); + const playerRef = useRef(null); + React.useEffect(() => { + setIsVideo(ReactPlayer.canPlay(url)); + }, [url]); + if (isVideo) { + return ( + //
+ // + //
+
+ +
+ ); + } + else { + return ( +
+ +
+ ); + } + } +} + export default function TipNotification({ ...props }) { const classes = useStyles() const [status, setStatus] = useState("Yes") @@ -160,9 +265,21 @@ export default function TipNotification({ ...props }) { {!!props.images ? {props.title} : ""} {!!props.details ? - {props.details} + + // ReactPlayer.canPlay(href) ? ( + href ? ( + + ) : ( + {children} + ), + }}> + {props.details} + : ""} - +