aboutsummaryrefslogtreecommitdiff
path: root/components/videoPlayer.js
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-04-13 16:03:57 +0700
committerFactiven <[email protected]>2023-04-13 16:03:57 +0700
commitb365d89a11adf40d37b78292f121b890e960d0e8 (patch)
tree6bd745c773dc48a2e5e4c18d2f71d54d82d682fd /components/videoPlayer.js
parentupdate 1 (diff)
downloadmoopa-b365d89a11adf40d37b78292f121b890e960d0e8.tar.xz
moopa-b365d89a11adf40d37b78292f121b890e960d0e8.zip
update 2nd
Diffstat (limited to 'components/videoPlayer.js')
-rw-r--r--components/videoPlayer.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/components/videoPlayer.js b/components/videoPlayer.js
index c680430..e568772 100644
--- a/components/videoPlayer.js
+++ b/components/videoPlayer.js
@@ -1,10 +1,22 @@
import Player from "../lib/Artplayer";
import { useEffect, useState } from "react";
+import { useAniList } from "../lib/useAnilist";
-export default function VideoPlayer({ data, seek, titles, id }) {
+export default function VideoPlayer({
+ data,
+ seek,
+ titles,
+ id,
+ progress,
+ session,
+ aniId,
+}) {
const [url, setUrl] = useState();
const [source, setSource] = useState([]);
const [loading, setLoading] = useState(true);
+ const { markProgress } = useAniList(session);
+
+ // console.log(progress);
useEffect(() => {
async function compiler() {
@@ -70,6 +82,24 @@ export default function VideoPlayer({ data, seek, titles, id }) {
});
art.on("destroy", () => {
+ const currentTime = art.currentTime;
+ const duration = art.duration;
+ const percentage = currentTime / duration;
+
+ if (percentage >= 0.9) {
+ // use >= instead of >
+ markProgress(aniId, progress);
+ } else {
+ console.log("Something went wrong");
+ }
+ });
+
+ art.on("video:ended", () => {
+ art.destroy();
+ console.log("Video ended");
+ });
+
+ art.on("destroy", () => {
const lastPlayed = {
id: id,
time: art.currentTime,