diff --git a/app/(site)/popular/container.tsx b/app/(site)/popular/container.tsx
index 82cc863..f885947 100644
--- a/app/(site)/popular/container.tsx
+++ b/app/(site)/popular/container.tsx
@@ -2,7 +2,6 @@
import List from '@/components/List';
import NoResults from '@/components/NoResults';
-import { Player } from '@/components/Show/components/Torrents/components/Player';
import usePopular from './usePopular';
@@ -11,15 +10,7 @@ const Container = () => {
if (isFetched && !shows.length) return ;
- return (
- <>
-
-
- >
- );
+ return
;
};
export default Container;
diff --git a/app/layout.tsx b/app/layout.tsx
index 8154331..e5c0690 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,15 +1,12 @@
import React, { ReactNode } from 'react';
import type { Metadata, Viewport } from 'next';
-import { Poppins } from 'next/font/google';
import { cookies } from 'next/headers';
-const poppins = Poppins({ subsets: ['latin'], weight: '400' });
-
import Header from '@/components/Header';
import Providers from '@/providers';
+import { font } from '@/styles/font';
import '@/styles/index.css';
-import '@/styles/player.css';
export const metadata: Metadata = {
title: 'Movie advisor | Discover Your Next Favorite Movie',
@@ -33,7 +30,7 @@ const RootLayout = ({ children }: { children: ReactNode }) => {
-
+
diff --git a/components/Show/components/Torrents/components/Player/components/CaptionsMenu/index.tsx b/components/Show/components/Torrents/components/Player/components/CaptionsMenu/index.tsx
new file mode 100644
index 0000000..d35238f
--- /dev/null
+++ b/components/Show/components/Torrents/components/Player/components/CaptionsMenu/index.tsx
@@ -0,0 +1,22 @@
+import { useActiveTextTrack, useCaptionOptions } from '@vidstack/react';
+import { ClosedCaptionsIcon, ClosedCaptionsOnIcon } from '@vidstack/react/icons';
+
+import { cn } from '@/lib/utils';
+
+import PlayerMenu from '../PlayerMenu';
+
+const CaptionsMenu = () => {
+ const track = useActiveTextTrack(['subtitles']);
+ const tracks = useCaptionOptions();
+
+ return (
+
({ label: track.label, onClick: () => track.select() }))}
+ isChecked={({ label }) => (label === 'Off' ? !track : label === track?.label)}
+ >
+ {track ? : }
+
+ );
+};
+
+export default CaptionsMenu;
diff --git a/components/Show/components/Torrents/components/Player/components/PlayerMenu/index.tsx b/components/Show/components/Torrents/components/Player/components/PlayerMenu/index.tsx
index 12cd995..25969c4 100644
--- a/components/Show/components/Torrents/components/Player/components/PlayerMenu/index.tsx
+++ b/components/Show/components/Torrents/components/Player/components/PlayerMenu/index.tsx
@@ -13,17 +13,17 @@ interface Props {
}
const PlayerMenu: FC
= ({ children, options, isChecked }) => (
-
-
+
+
{children}
-
+
{options.map((option) => (
diff --git a/components/Show/components/Torrents/components/Player/components/VideosMenu/index.tsx b/components/Show/components/Torrents/components/Player/components/VideosMenu/index.tsx
new file mode 100644
index 0000000..43f966b
--- /dev/null
+++ b/components/Show/components/Torrents/components/Player/components/VideosMenu/index.tsx
@@ -0,0 +1,23 @@
+import { FC } from 'react';
+import { PlaylistIcon } from '@vidstack/react/icons';
+
+import { cn } from '@/lib/utils';
+
+import PlayerMenu from '../PlayerMenu';
+
+interface Props {
+ source: Source;
+ sources: Source[];
+ onChange: (index: number) => void;
+}
+
+const VideosMenu: FC = ({ sources, source, onChange }) => (
+ ({ label: name, onClick: () => onChange(index) }))}
+ isChecked={({ label }) => source.name === label}
+ >
+
+
+);
+
+export default VideosMenu;
diff --git a/components/Show/components/Torrents/components/Player/index.tsx b/components/Show/components/Torrents/components/Player/index.tsx
index d6765a5..36c87d5 100644
--- a/components/Show/components/Torrents/components/Player/index.tsx
+++ b/components/Show/components/Torrents/components/Player/index.tsx
@@ -1,119 +1,84 @@
'use client';
-import { FC, useRef } from 'react';
+import { useRef, useState } from 'react';
import { create, InstanceProps } from 'react-modal-promise';
-import {
- MediaPlayer,
- MediaPlayerInstance,
- MediaProvider,
- Poster,
- Track,
- useActiveTextTrack,
- useCaptionOptions,
- useMediaPlayer,
- useMediaStore,
- VideoSrc
-} from '@vidstack/react';
-import { ClosedCaptionsIcon, ClosedCaptionsOnIcon, PlaylistIcon } from '@vidstack/react/icons';
+import { MediaPlayer, MediaPlayerInstance, MediaProvider, Poster, Track, VideoSrc } from '@vidstack/react';
import { defaultLayoutIcons, DefaultVideoLayout } from '@vidstack/react/player/layouts/default';
import { Modal } from '@/components/ui/dialog';
import { useToast } from '@/hooks/useToast';
import { cn } from '@/lib/utils';
-import PlayerMenu from './components/PlayerMenu';
+import CaptionsMenu from './components/CaptionsMenu';
+import VideosMenu from './components/VideosMenu';
import useFiles from './useFiles';
import '@vidstack/react/player/styles/default/theme.css';
import '@vidstack/react/player/styles/default/layouts/video.css';
-interface Props {
+interface Props extends InstanceProps {
magnet: string;
backdrop: string;
className?: string;
+ onClose: () => void;
}
-const CaptionsMenu = () => {
- const track = useActiveTextTrack(['subtitles']);
- const tracks = useCaptionOptions();
+const showPlayer = create(({ onResolve, magnet, backdrop, className }: Props) => {
+ const [index, setIndex] = useState(0);
- return (
- ({ label: track.label, onClick: () => track.select() }))}
- isChecked={({ label }) => (label === 'Off' ? !track : label === track?.label)}
- >
- {track ? : }
-
- );
-};
-
-const VideosMenu = () => {
- const player = useMediaPlayer();
- const { sources, source } = useMediaStore();
-
- player?.remoteControl.console.log(sources, source);
-
- return null;
-
- return (
- ({ label: track.label, onClick: () => track.select() }))}
- isChecked={({ label }) => (label === 'Off' ? !track : label === track?.label)}
- >
- {track ? : }
-
- );
-};
-
-export const Player: FC = ({ magnet, backdrop, className }) => {
- const { toast } = useToast();
const player = useRef(null);
const {
- data: { subtitles, videos }
+ data: { subtitles, videos },
+ isFetched
} = useFiles(magnet);
- return (
-
-
-
- {subtitles.map((track) => (
-
- ))}
-
- ,
- afterSettingsMenu: Boolean(subtitles.length) &&
- }}
- />
-
- );
-};
+ const source = videos[index];
+
+ const { toast } = useToast();
+
+ if (isFetched && !videos.length) {
+ toast({ description: 'This torrent doesn\'t contain any compatible video files' });
+ onResolve();
+ }
-const showPlayer = create(({ onResolve, magnet, backdrop, className }: Props & InstanceProps) => {
return (
-
+
+
+
+ {subtitles.map((track) => (
+
+ ))}
+
+ 1) && (
+
+ ),
+ afterSettingsMenu: Boolean(subtitles.length) &&
+ }}
+ />
+
);
});
diff --git a/package-lock.json b/package-lock.json
index 74a4026..bab73e5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -39,15 +39,13 @@
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.6",
"typescript": "5.1.6",
- "vaul": "^0.8.9",
- "video-react": "^0.16.0"
+ "vaul": "^0.8.9"
},
"devDependencies": {
"@types/js-cookie": "^3.0.3",
"@types/node": "20.4.4",
"@types/react": "18.2.15",
"@types/react-dom": "18.2.7",
- "@types/video-react": "^0.15.8",
"autoprefixer": "^10.4.14",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-tailwindcss": "^3.17.4",
@@ -2121,15 +2119,6 @@
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz",
"integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ=="
},
- "node_modules/@types/video-react": {
- "version": "0.15.8",
- "resolved": "https://registry.npmjs.org/@types/video-react/-/video-react-0.15.8.tgz",
- "integrity": "sha512-ZFm57z6bwJ1FWMKAMXyDar0OAQCchals2T4mDG//JXeToW3C2dADI2MzX5y53tFL77Y2QAA1YQZh5XTL1rjiqw==",
- "dev": true,
- "dependencies": {
- "@types/react": "*"
- }
- },
"node_modules/@typescript-eslint/parser": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz",
@@ -5104,11 +5093,6 @@
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
},
- "node_modules/lodash.throttle": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",
- "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ=="
- },
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@@ -6006,14 +5990,6 @@
"node": ">=8.10.0"
}
},
- "node_modules/redux": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz",
- "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==",
- "dependencies": {
- "@babel/runtime": "^7.9.2"
- }
- },
"node_modules/reflect.getprototypeof": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz",
@@ -7010,22 +6986,6 @@
"react-dom": "^16.8 || ^17.0 || ^18.0"
}
},
- "node_modules/video-react": {
- "version": "0.16.0",
- "resolved": "https://registry.npmjs.org/video-react/-/video-react-0.16.0.tgz",
- "integrity": "sha512-138NHPS8bmgqCYVCdbv2GVFhXntemNHWGw9AN8iJSzr3jizXMmWJd2LTBppr4hZJUbyW1A1tPZ3CQXZUaexMVA==",
- "dependencies": {
- "@babel/runtime": "^7.4.5",
- "classnames": "^2.2.6",
- "lodash.throttle": "^4.1.1",
- "prop-types": "^15.7.2",
- "redux": "^4.0.1"
- },
- "peerDependencies": {
- "react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
- "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
- }
- },
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@@ -8330,15 +8290,6 @@
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz",
"integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ=="
},
- "@types/video-react": {
- "version": "0.15.8",
- "resolved": "https://registry.npmjs.org/@types/video-react/-/video-react-0.15.8.tgz",
- "integrity": "sha512-ZFm57z6bwJ1FWMKAMXyDar0OAQCchals2T4mDG//JXeToW3C2dADI2MzX5y53tFL77Y2QAA1YQZh5XTL1rjiqw==",
- "dev": true,
- "requires": {
- "@types/react": "*"
- }
- },
"@typescript-eslint/parser": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz",
@@ -10388,11 +10339,6 @@
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
},
- "lodash.throttle": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",
- "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ=="
- },
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@@ -10956,14 +10902,6 @@
"picomatch": "^2.2.1"
}
},
- "redux": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz",
- "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==",
- "requires": {
- "@babel/runtime": "^7.9.2"
- }
- },
"reflect.getprototypeof": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz",
@@ -11619,18 +11557,6 @@
"@radix-ui/react-dialog": "^1.0.4"
}
},
- "video-react": {
- "version": "0.16.0",
- "resolved": "https://registry.npmjs.org/video-react/-/video-react-0.16.0.tgz",
- "integrity": "sha512-138NHPS8bmgqCYVCdbv2GVFhXntemNHWGw9AN8iJSzr3jizXMmWJd2LTBppr4hZJUbyW1A1tPZ3CQXZUaexMVA==",
- "requires": {
- "@babel/runtime": "^7.4.5",
- "classnames": "^2.2.6",
- "lodash.throttle": "^4.1.1",
- "prop-types": "^15.7.2",
- "redux": "^4.0.1"
- }
- },
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
diff --git a/package.json b/package.json
index edcf978..a0e5ecb 100644
--- a/package.json
+++ b/package.json
@@ -40,15 +40,13 @@
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.6",
"typescript": "5.1.6",
- "vaul": "^0.8.9",
- "video-react": "^0.16.0"
+ "vaul": "^0.8.9"
},
"devDependencies": {
"@types/js-cookie": "^3.0.3",
"@types/node": "20.4.4",
"@types/react": "18.2.15",
"@types/react-dom": "18.2.7",
- "@types/video-react": "^0.15.8",
"autoprefixer": "^10.4.14",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-tailwindcss": "^3.17.4",
diff --git a/styles/font.ts b/styles/font.ts
new file mode 100644
index 0000000..f50cb33
--- /dev/null
+++ b/styles/font.ts
@@ -0,0 +1,3 @@
+import { Poppins } from 'next/font/google';
+
+export const font = Poppins({ subsets: ['latin'], variable: '--font-family', weight: '400' });
diff --git a/styles/index.css b/styles/index.css
index 0dfa5fd..8ea8743 100644
--- a/styles/index.css
+++ b/styles/index.css
@@ -2,8 +2,6 @@
@tailwind components;
@tailwind utilities;
-@import url('video-react/dist/video-react.css');
-
@layer base {
:root {
--background: 0 0% 100%;
@@ -89,6 +87,12 @@
body {
@apply bg-background text-foreground;
}
+
+ :where(.vds-time),
+ :where(.vds-menu-items),
+ :where(.vds-video-layout) {
+ --media-font-family: var(--font-family);
+ }
}
@layer utilities {
diff --git a/styles/player.css b/styles/player.css
deleted file mode 100644
index f2f8869..0000000
--- a/styles/player.css
+++ /dev/null
@@ -1,33 +0,0 @@
-.video-react,
-.video-react-menu .video-react-menu-content,
-.video-react-control-text {
- font-family: system-ui;
-}
-
-.video-react .video-react-menu-button-popup .video-react-menu {
- right: 0;
- left: auto;
- width: 200px;
- border-radius: 4px;
-}
-
-.video-react-menu li {
- padding-inline: 0.5rem;
- white-space: nowrap;
- overflow: hidden;
- max-width: 100%;
- text-overflow: ellipsis;
-}
-
-.video-react-menu li:first-child {
- border-top-left-radius: 4px;
- border-top-right-radius: 4px;
-}
-
-.video-react .video-react-big-play-button.video-react-big-play-button-center {
- display: none;
-}
-
-.video-react .video-react-menu-button-popup .video-react-menu .video-react-menu-content {
- overflow: hidden;
-}
diff --git a/tailwind.config.js b/tailwind.config.js
index 7c52820..ba14aa3 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -87,5 +87,12 @@ module.exports = {
corePlugins: {
aspectRatio: false
},
- plugins: [require('tailwindcss-animate'), require('tailwindcss-touch')()]
+ plugins: [
+ require('tailwindcss-animate'),
+ require('tailwindcss-touch')(),
+ require('@vidstack/react/tailwind.cjs')({
+ selector: '.media-player',
+ prefix: 'media'
+ })
+ ]
};