From 4b1ede713011fc4bfe718f63f31f3ed89b97534e Mon Sep 17 00:00:00 2001 From: Benjamin Jones Date: Wed, 26 May 2021 15:47:59 +0200 Subject: [PATCH] added video embed for archive episodes --- src/components/Info/index.js | 35 ++++++++++++++++++++---------- src/components/Info/styles.js | 25 +++++++++++---------- src/components/VideoEmbed/index.js | 3 +-- src/data/config.js | 3 +-- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/components/Info/index.js b/src/components/Info/index.js index 5237c06..7efe87e 100644 --- a/src/components/Info/index.js +++ b/src/components/Info/index.js @@ -7,7 +7,7 @@ import { H1 } from '../Text' import Markdown from '../Markdown' import translations from '../../data/strings' import InfoLayout from '../InfoLayout' -import TrailerEmbed from '../VideoEmbed' +import VideoEmbed from '../VideoEmbed' import { VideoCard, Title, @@ -26,9 +26,16 @@ import config from '../../data/config' import trailerThumb from '../../assets/img/main_thumb.png' const Info = ({ data, loading, infoActive, setInfoActive, currentVideo }) => { - const [trailerActive, setTrailerActive] = useState(false) - const toggleTrailerActive = () => - setTrailerActive(trailerState => !trailerState) + const trailerUrl = `https://www.youtube-nocookie.com/embed/${config.seriesTrailerId}?autoplay=1&vq=hd1080` + const [embedURL, setEmbedUrl] = useState('') + + const onClickTrailerButton = () => { + setEmbedUrl(trailerUrl) + } + const deactivateEmbed = () => { + setEmbedUrl('') + } + const pastStreams = data && data.length ? data.filter(feeditem => isPast(new Date(feeditem.end))) @@ -52,12 +59,9 @@ const Info = ({ data, loading, infoActive, setInfoActive, currentVideo }) => { return ( - {trailerActive && ( - - )} + {embedURL ? ( + + ) : null} {infoActive && ( setInfoActive(false)} /> )} @@ -68,7 +72,7 @@ const Info = ({ data, loading, infoActive, setInfoActive, currentVideo }) => {

Finding the Future in Unexpected Places

{intro} - + { {translations.en.pastStream}: {pastStreams.map(feeditem => ( - + + setEmbedUrl(`${config.peertube_root}${feeditem.embedPath}`) + } + {...feeditem} + /> ))} ) : null} diff --git a/src/components/Info/styles.js b/src/components/Info/styles.js index 375cbf4..7ad07da 100644 --- a/src/components/Info/styles.js +++ b/src/components/Info/styles.js @@ -183,6 +183,7 @@ export const VideoCard = ({ previewPath, hasPassed, videoUrl, + onClickButton, }) => { const startDate = new Date(start) const utcDate = zonedTimeToUtc(startDate, 'Europe/Berlin') @@ -211,17 +212,19 @@ export const VideoCard = ({ )}

{description}

-
- - + {hasPassed ? ( + + ) : ( + + + + )} ) } diff --git a/src/components/VideoEmbed/index.js b/src/components/VideoEmbed/index.js index b2d280d..e71014f 100644 --- a/src/components/VideoEmbed/index.js +++ b/src/components/VideoEmbed/index.js @@ -14,7 +14,6 @@ const Video = ({ url, onClose }) => { overlayTimeout.current = null setOverlayActiveState(true) - console.log('overlayTimeout.current', overlayTimeout.current) overlayTimeout.current = setTimeout( () => setOverlayActiveState(false), 1500 @@ -29,7 +28,7 @@ const Video = ({ url, onClose }) => { onMouseMove={activateOverlay} width="560" height="315" - src="https://www.youtube-nocookie.com/embed/b-JQ5Bo4JnI?autoplay=1&vq=hd1080" + src={url} frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen diff --git a/src/data/config.js b/src/data/config.js index 0199883..1f6bbdf 100644 --- a/src/data/config.js +++ b/src/data/config.js @@ -1,7 +1,6 @@ export default { peertube_root: 'https://tv.undersco.re', - seriesTrailer: - 'https://tv.undersco.re/videos/embed/5e29327c-41de-4b48-b567-ee28b181336f', + seriesTrailerId: 'b-JQ5Bo4JnI', calendarId: '9FzomgAfidHWCQcx', chat: {