aboutsummaryrefslogtreecommitdiff
path: root/src/app/web-series/components/videoPlayer.jsx
blob: cc8feb343c390e3bfe2a812ffb73a59926c25a6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"use client";

import { useState } from "react";
import styles from "../styles/videoPlayer.module.css";

const SeriesPlayer = ({ id: id }) => {
	const [iframe, iframeContent] = useState(null);
	const [episode, setEpisode] = useState("");
	const [season, setSeason] = useState("");

	async function VideoPlayerInitialize() {
		if (!episode || !season) {
			alert("Please provide the required episode and season number.");
			return;
		}
		iframeContent(await iframeGenerator(id, season, episode));
		document.getElementById("video-player").style.display = "none";
	}

	return (
		<main className={styles.Main}>
			<div className={styles.EpisodeSeasonInput}>
				<input
					name="Season"
					type="number"
					placeholder="Season Number"
					onChange={(e) => {
						if (Number(e.target.value) > 0) {
							setSeason(e.target.value);
						}
					}}
				></input>
				<input
					name="Episode"
					type="number"
					placeholder="Episode Number"
					onChange={(e) => {
						if (Number(e.target.value) > 0) {
							setEpisode(e.target.value);
						}
					}}
				></input>

				<button onClick={() => VideoPlayerInitialize(id)}>
					Search
				</button>
			</div>

			<div className={styles.VideoPlayer}>
				{iframe}
				<p id="video-player">
					Please use adblockers to prevent ads and redirects. We have
					no control over the amount of ads or the type of ads which
					you might encounter.
				</p>
			</div>
		</main>
	);
};

const iframeGenerator = async (id, seasonNumber, episodeNumber) => {
	const url = `https://vidsrc.pro/embed/tv/${id}/${seasonNumber}/${episodeNumber}`;
	return <iframe src={url} allowFullScreen referrerPolicy="origin"></iframe>;
};

export default SeriesPlayer;