Skip to content

Commit

Permalink
VideoPlayer Bugfixes
Browse files Browse the repository at this point in the history
Videoplayer doesn't set fill ObjectFit when fullscreen.

Added ObjectFit button

Volume slider doesn't clip into video time label

Volume and Progress sliders have a smaller click range so they don't override other video buttons.

Usernames in the videolist component now show ellipses when they overflow

Hyperlink color throughout the app changed so they are easier to see
  • Loading branch information
QortalSeth committed Jan 2, 2025
1 parent 1cfdb7a commit d4f5c7a
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Box, IconButton, Menu, MenuItem } from "@mui/material";
import { useVideoContext } from "./VideoContext.ts";
import {
FullscreenButton,
ObjectFitButton,
PictureInPictureButton,
PlaybackRate,
PlayButton,
Expand Down Expand Up @@ -55,7 +56,10 @@ export const MobileControlsBar = () => {
>
<MenuItem>
<VolumeButton />
<VolumeSlider />
<VolumeSlider width={"100%"} />
</MenuItem>
<MenuItem>
<ObjectFitButton />
</MenuItem>
<MenuItem>
<PictureInPictureButton />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ export const useVideoControlsState = (
}
};

const setStretchVideoSetting = (value: "contain" | "fill") => {
const setObjectFit = (value: "contain" | "fill") => {
videoObjectFit.value = value;
};

const toggleStretchVideoSetting = () => {
const toggleObjectFit = () => {
videoObjectFit.value =
videoObjectFit.value === "contain" ? "fill" : "contain";
};
Expand All @@ -226,7 +226,7 @@ export const useVideoControlsState = (

switch (e.key) {
case "o":
toggleStretchVideoSetting();
toggleObjectFit();
break;

case Key.Add:
Expand Down Expand Up @@ -364,6 +364,7 @@ export const useVideoControlsState = (
showControlsFullScreen,
setPlaying,
isFullscreen,
setStretchVideoSetting,
toggleObjectFit,
setObjectFit,
};
};
31 changes: 26 additions & 5 deletions src/components/common/VideoPlayer/Components/VideoControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fontSizeExSmall, fontSizeSmall } from "../../../../constants/Misc.ts";
import { CustomFontTooltip } from "../../../../utils/CustomFontTooltip.tsx";
import { formatTime } from "../../../../utils/numberFunctions.ts";
import { useVideoContext } from "./VideoContext.ts";
import AspectRatioIcon from "@mui/icons-material/AspectRatio";
import {
Fullscreen,
Pause,
Expand Down Expand Up @@ -48,7 +49,6 @@ export const ReloadButton = () => {

export const ProgressSlider = () => {
const { progress, onProgressChange, videoRef } = useVideoContext();
const sliderThumbSize = "16px";
return (
<Slider
value={progress.value}
Expand All @@ -65,9 +65,10 @@ export const ProgressSlider = () => {

"& .MuiSlider-thumb": {
backgroundColor: "#fff",
width: sliderThumbSize,
height: sliderThumbSize,
width: "16px",
height: "16px",
},
"& .MuiSlider-thumb::after": { width: "20px", height: "20px" },
"& .MuiSlider-rail": { opacity: 0.5 },
}}
/>
Expand Down Expand Up @@ -112,6 +113,7 @@ export const VolumeButton = () => {
<IconButton
sx={{
color: "white",
marginRight: "10px",
}}
onClick={toggleMute}
>
Expand All @@ -121,7 +123,7 @@ export const VolumeButton = () => {
);
};

export const VolumeSlider = () => {
export const VolumeSlider = ({ width }: { width: string }) => {
const { volume, onVolumeChange } = useVideoContext();
return (
<Slider
Expand All @@ -131,7 +133,9 @@ export const VolumeSlider = () => {
max={1}
step={0.01}
sx={{
width: "100px",
width,
marginRight: "10px",
"& .MuiSlider-thumb::after": { width: "25px", height: "25px" },
}}
/>
);
Expand Down Expand Up @@ -183,6 +187,23 @@ export const PictureInPictureButton = () => {
);
};

export const ObjectFitButton = () => {
const { toggleObjectFit } = useVideoContext();
return (
<CustomFontTooltip title="Toggle Aspect Ratio (O)" placement="top" arrow>
<IconButton
sx={{
color: "white",
paddingRight: "0px",
}}
onClick={() => toggleObjectFit()}
>
<AspectRatioIcon />
</IconButton>
</CustomFontTooltip>
);
};

export const FullscreenButton = () => {
const { toggleFullscreen } = useVideoContext();
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MobileControlsBar } from "./MobileControlsBar.tsx";
import { useVideoContext } from "./VideoContext.ts";
import {
FullscreenButton,
ObjectFitButton,
PictureInPictureButton,
PlaybackRate,
PlayButton,
Expand Down Expand Up @@ -46,12 +47,13 @@ export const VideoControlsBar = () => {
<ProgressSlider />

<VolumeButton />
<VolumeSlider />
<VolumeSlider width={"100px"} />
<VideoTime />
</Box>

<Box sx={controlGroupSX}>
<PlaybackRate />
<ObjectFitButton />
<PictureInPictureButton />
<FullscreenButton />
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/VideoPlayer/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const VideoPlayer = forwardRef<videoRefType, VideoPlayerProps>(
preload="metadata"
style={{
...videoStyles?.video,
objectFit: isFullscreen ? "fill" : videoObjectFit.value,
objectFit: videoObjectFit.value,
height:
isFullscreen.value && showControlsFullScreen.value
? "calc(100vh - 40px)"
Expand Down
2 changes: 1 addition & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
height: 100%;
}


a:link { color: #8AB4F8}

.test-grid {
display: grid;
Expand Down
13 changes: 6 additions & 7 deletions src/pages/ContentPages/VideoContent/VideoContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,17 @@ export const VideoContent = () => {
cursor: !descriptionHeight
? "default"
: isExpandedDescription
? "default"
: "pointer",
? "default"
: "pointer",
position: "relative",

marginBottom: "30px",
}}
className={
!descriptionHeight
? ""
: isExpandedDescription
? ""
: "hover-click"
? ""
: "hover-click"
}
>
{descriptionHeight && !isExpandedDescription && (
Expand All @@ -210,8 +209,8 @@ export const VideoContent = () => {
height: !descriptionHeight
? "auto"
: isExpandedDescription
? "auto"
: "200px",
? "auto"
: "200px",
overflow: "hidden",
}}
>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Home/Components/VideoList-styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const NameContainer = styled(Box)(({ theme }) => ({
alignItems: "center",
gap: "10px",
marginBottom: "2px",
width: "100%",
}));

export const VideoManagerRow = styled(Box)(({ theme }) => ({
Expand Down
Loading

0 comments on commit d4f5c7a

Please sign in to comment.