Skip to content

fix yarn build issues and made sure yarn install step is in readme #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@

## Prerequests

### Yarn Install
Make sure npm packages are installed with yarn to generate `yarn.lock` file.
```
yarn install
```

### The Movie Database
- Create an account if you don't have on [TMDB](https://www.themoviedb.org/).
Because I use its free API to consume movie/tv data.
- And then follow the [documentation](https://developers.themoviedb.org/3/getting-started/introduction) to create API Key
Expand Down
2 changes: 1 addition & 1 deletion src/components/DetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function DetailModal() {

const handleReady = useCallback((player: Player) => {
playerRef.current = player;
setMuted(player.muted());
setMuted(player.muted() || false);
}, []);

const handleMute = useCallback((status: boolean) => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/watch/VolumeControllers.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Stack } from "@mui/material";
import Slider from "@mui/material/Slider";
import { styled } from "@mui/material/styles";
import { SliderUnstyledOwnProps } from "@mui/base/SliderUnstyled";
import VolumeUpIcon from "@mui/icons-material/VolumeUp";
import VolumeOffIcon from "@mui/icons-material/VolumeOff";
import PlayerControlButton from "./PlayerControlButton";
Expand Down Expand Up @@ -34,14 +33,16 @@ const StyledSlider = styled(Slider)({
},
});

import { SliderTypeMap } from "@mui/material/Slider";

export default function VolumeControllers({
value,
handleVolume,
handleVolumeToggle,
muted,
}: {
value: number;
handleVolume: SliderUnstyledOwnProps["onChange"];
handleVolume: SliderTypeMap["props"]["onChange"];
handleVolumeToggle: React.MouseEventHandler<HTMLButtonElement>;
muted: boolean;
}) {
Expand Down
13 changes: 7 additions & 6 deletions src/pages/WatchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useState, useRef, useMemo } from "react";
import { useNavigate } from "react-router-dom";
import Player from "video.js/dist/types/player";
import { Box, Stack, Typography } from "@mui/material";
import { SliderUnstyledOwnProps } from "@mui/base/SliderUnstyled";
import PlayArrowIcon from "@mui/icons-material/PlayArrow";
import PauseIcon from "@mui/icons-material/Pause";
import SkipNextIcon from "@mui/icons-material/SkipNext";
Expand All @@ -21,6 +20,8 @@ import PlayerSeekbar from "src/components/watch/PlayerSeekbar";
import PlayerControlButton from "src/components/watch/PlayerControlButton";
import MainLoadingScreen from "src/components/MainLoadingScreen";

import { SliderTypeMap } from "@mui/material/Slider";

export function Component() {
const playerRef = useRef<Player | null>(null);
const [playerState, setPlayerState] = useState({
Expand Down Expand Up @@ -72,13 +73,13 @@ export function Component() {

player.on("timeupdate", () => {
setPlayerState((draft) => {
return { ...draft, playedSeconds: player.currentTime() };
return { ...draft, playedSeconds: player.currentTime() ?? 0 };
});
});

player.one("durationchange", () => {
setPlayerInitialized(true);
setPlayerState((draft) => ({ ...draft, duration: player.duration() }));
setPlayerState((draft) => ({ ...draft, duration: player.duration() ?? 0 }));
});

playerRef.current = player;
Expand All @@ -88,10 +89,10 @@ export function Component() {
});
};

const handleVolumeChange: SliderUnstyledOwnProps["onChange"] = (_, value) => {
playerRef.current?.volume((value as number) / 100);
const handleVolumeChange: SliderTypeMap["props"]["onChange"] = (event: any, value: number | number[]) => {
playerRef.current?.volume(Array.isArray(value) ? value[0] / 100 : value / 100);
setPlayerState((draft) => {
return { ...draft, volume: (value as number) / 100 };
return { ...draft, volume: Array.isArray(value) ? value[0] / 100 : value / 100 };
});
};

Expand Down