From 7bd243f26e9e0951eccfe2834c0c7b37a33637f0 Mon Sep 17 00:00:00 2001 From: Prajwal Kulkarni Date: Sun, 21 Jul 2024 13:17:41 +0530 Subject: [PATCH] Add secondary media src --- src/components/Episode.tsx | 17 +++- src/components/MediaPortal.tsx | 35 +++++--- src/components/Seasons.tsx | 63 ++++++-------- src/context/Context.tsx | 1 - src/pages/Home.tsx | 23 +---- src/pages/Landing.tsx | 1 - src/pages/Movie.tsx | 150 +++++++++++---------------------- 7 files changed, 119 insertions(+), 171 deletions(-) diff --git a/src/components/Episode.tsx b/src/components/Episode.tsx index 8f1c908..a86f0af 100644 --- a/src/components/Episode.tsx +++ b/src/components/Episode.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import PlayCircleOutlineIcon from "@mui/icons-material/PlayCircleOutline"; import ReactDOM from "react-dom"; import MediaPortal from "./MediaPortal"; @@ -15,7 +15,8 @@ type Props = { const Episode: React.FC = (props) => { const { image, imdbID, season, episode, name, overview, air_date } = props; - const [play, setPlay] = React.useState(false); + const [play, setPlay] = useState(false); + const [src, setSrc] = useState(0); return (
@@ -26,6 +27,7 @@ const Episode: React.FC = (props) => { imdbID={imdbID} onClick={() => setPlay(false)} season={season} + src={src} episode={episode} />, document.getElementById("portal") as HTMLElement @@ -39,11 +41,20 @@ const Episode: React.FC = (props) => {

{name}

{overview}

Air Date: {air_date}

-
+
setPlay(true)}> Watch + { + setPlay(true); + setSrc(1); + }} + > + Watch #2 +
diff --git a/src/components/MediaPortal.tsx b/src/components/MediaPortal.tsx index 6922f48..5070f67 100644 --- a/src/components/MediaPortal.tsx +++ b/src/components/MediaPortal.tsx @@ -7,33 +7,48 @@ const MediaPortal: React.FC<{ episode?: number; season?: number; onClick: React.MouseEventHandler; + src: number; }> = (props) => { - const { mediaType, imdbID, season, episode } = props; + const { mediaType, imdbID, season, episode, onClick, src } = props; - const vidSrc = `${ - mediaType === "series" - ? "tv/" + imdbID + "/" + season + "/" + episode - : "movie/" + imdbID - }`; + let vidSrc = ""; + + if (src === 0) { + vidSrc = `${ + mediaType === "series" + ? "tv/" + imdbID + "/" + season + "/" + episode + : "movie/" + imdbID + }`; + } else { + vidSrc = `${ + mediaType === "series" + ? "tv/" + imdbID + "/" + season + "-" + episode + : "movie/" + imdbID + }`; + } + + let mediaSrc = + src === 0 + ? process.env.REACT_APP_PLAYER_URL + : process.env.REACT_APP_PLAYER_URL_SECONDARY; return (