aboutsummaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-05-18 15:46:10 +0700
committerFactiven <[email protected]>2023-05-18 15:46:10 +0700
commit759120279dbd83f787cc1005c0015955f8d64bc9 (patch)
treebe8d7dc74fe4a31d98dddbe59961e227649c49ec /components
parentUpdate [param].js (diff)
downloadmoopa-759120279dbd83f787cc1005c0015955f8d64bc9.tar.xz
moopa-759120279dbd83f787cc1005c0015955f8d64bc9.zip
Emergency Update
> Temporary switching to zoro as a source until the API works again
Diffstat (limited to 'components')
-rw-r--r--components/videoPlayer.js71
1 files changed, 56 insertions, 15 deletions
diff --git a/components/videoPlayer.js b/components/videoPlayer.js
index b57799e..f34eab7 100644
--- a/components/videoPlayer.js
+++ b/components/videoPlayer.js
@@ -16,6 +16,8 @@ export default function VideoPlayer({
}) {
const [url, setUrl] = useState();
const [source, setSource] = useState([]);
+ const [subtitle, setSubtitle] = useState();
+ const [defSub, setDefSub] = useState();
const { markProgress } = useAniList(session);
useEffect(() => {
@@ -35,19 +37,40 @@ export default function VideoPlayer({
source.quality === "144p"
);
- const source = data.sources.map((items) => ({
- default: items.quality === "default" ? true : false,
- html: items.quality === "default" ? "adaptive" : items.quality,
- // url: `https://cors.moopa.my.id/${items.url}`,
- url: `https://cors.moopa.my.id/?url=${encodeURIComponent(items.url)}${
- referer ? `&referer=${encodeURIComponent(referer)}` : ""
- }`,
- }));
-
- // const defUrl = `https://cors.moopa.my.id/${sumber.url}`;
- const defUrl = `https://cors.moopa.my.id/?url=${encodeURIComponent(
- sumber.url
- )}${referer ? `&referer=${encodeURIComponent(referer)}` : ""}`;
+ const source = data.sources.map((items) => {
+ const isDefault =
+ items.quality === "default" || items.quality === "auto";
+ return {
+ ...(isDefault && { default: true }),
+ html: items.quality === "default" ? "adaptive" : items.quality,
+ url: `https://lerioproxy.herokuapp.com/${items.url}`,
+ };
+ // url: `https://cors.moopa.my.id/?url=${encodeURIComponent(items.url)}${
+ // referer ? `&referer=${encodeURIComponent(referer)}` : ""
+ // }`,
+ });
+
+ const defUrl = `https://lerioproxy.herokuapp.com/${sumber.url}`;
+ // const defUrl = `https://cors.moopa.my.id/?url=${encodeURIComponent(
+ // sumber.url
+ // )}${referer ? `&referer=${encodeURIComponent(referer)}` : ""}`;
+
+ const subtitle = data?.subtitles
+ .filter((subtitle) => subtitle.lang !== "Thumbnails")
+ .map((subtitle) => {
+ const isEnglish = subtitle.lang === "English";
+ return {
+ ...(isEnglish && { default: true }),
+ url: subtitle.url,
+ html: `${subtitle.lang}`,
+ };
+ });
+
+ const defSub = data?.subtitles.filter((i) => i.lang === "English");
+ setDefSub(defSub);
+
+ // console.log(subtitle);
+ setSubtitle(subtitle);
setUrl(defUrl);
setSource(source);
@@ -65,12 +88,22 @@ export default function VideoPlayer({
key={url}
option={{
url: `${url}`,
- quality: [source],
title: `${title}`,
- autoplay: true,
+ // autoplay: true,
+ subtitle: {
+ url: defSub ? defSub[0].url : "",
+ type: "vtt",
+ encoding: "utf-8",
+ name: "English",
+ style: {
+ color: "#FFFF",
+ },
+ },
screenshot: true,
poster: poster ? poster : "",
}}
+ quality={source}
+ subtitles={subtitle}
style={{
width: "100%",
height: "100%",
@@ -83,6 +116,14 @@ export default function VideoPlayer({
const duration = art.duration;
const percentage = seekTime / duration;
+ // if (defSub) {
+ // art.subtitle.url = defSub[0].url;
+ // art.subtitle.style({
+ // color: "white",
+ // // fontSize: "40px",
+ // });
+ // }
+
if (percentage >= 0.9) {
// use >= instead of >
art.currentTime = 0;