added time for mobile

This commit is contained in:
PhilReact 2025-06-24 13:14:07 +03:00
parent 4249241ab7
commit 205da3ca24
7 changed files with 24 additions and 77 deletions

View File

@ -106,7 +106,6 @@ export const LoadingVideo = ({
sx={{ sx={{
cursor: "pointer", cursor: "pointer",
borderRadius: "10px",
position:"absolute", position:"absolute",
top:0, top:0,
left:0, left:0,
@ -114,6 +113,9 @@ export const LoadingVideo = ({
bottom:0, bottom:0,
zIndex: 501, zIndex: 501,
background: 'rgba(0,0,0,0.3)', background: 'rgba(0,0,0,0.3)',
padding: '0px',
borderRadius: "0px",
}} }}
> >
<PlayArrow <PlayArrow

View File

@ -1,6 +1,6 @@
import { alpha, Box, IconButton } from "@mui/material"; import { alpha, Box, IconButton } from "@mui/material";
import React from "react"; import React from "react";
import { ProgressSlider } from "./VideoControls"; import { ProgressSlider, VideoTime } from "./VideoControls";
import PlayArrowIcon from "@mui/icons-material/PlayArrow"; import PlayArrowIcon from "@mui/icons-material/PlayArrow";
import PauseIcon from "@mui/icons-material/Pause"; import PauseIcon from "@mui/icons-material/Pause";
import SubtitlesIcon from "@mui/icons-material/Subtitles"; import SubtitlesIcon from "@mui/icons-material/Subtitles";
@ -226,8 +226,15 @@ export const MobileControls = ({
width: "100%", width: "100%",
position: "absolute", position: "absolute",
bottom: 0, bottom: 0,
display: 'flex',
flexDirection: 'column'
}} }}
> >
<Box sx={{
padding: '0px 10px'
}}>
<VideoTime isScreenSmall progress={progress} duration={duration}/>
</Box>
<ProgressSlider <ProgressSlider
playerRef={playerRef} playerRef={playerRef}
progress={progress} progress={progress}

View File

@ -1,69 +0,0 @@
import { MoreVert as MoreIcon } from "@mui/icons-material";
import { Box, IconButton, Menu, MenuItem } from "@mui/material";
import {
FullscreenButton,
ObjectFitButton,
PictureInPictureButton,
PlaybackRate,
PlayButton,
ProgressSlider,
ReloadButton,
VideoTime,
VolumeControl,
} from "./VideoControls";
export const MobileControlsBar = ({handleMenuOpen, handleMenuClose, anchorEl, controlsHeight}) => {
const controlGroupSX = {
display: "flex",
gap: "5px",
alignItems: "center",
height: controlsHeight,
};
return (
<>
<Box sx={controlGroupSX}>
<PlayButton />
<ReloadButton />
<ProgressSlider />
<VideoTime />
</Box>
<Box sx={controlGroupSX}>
<PlaybackRate />
<FullscreenButton />
<IconButton
edge="end"
color="inherit"
aria-label="menu"
onClick={handleMenuOpen}
sx={{ paddingLeft: "0px", marginRight: "0px" }}
>
<MoreIcon />
</IconButton>
</Box>
<Menu
id="simple-menu"
anchorEl={anchorEl.value}
keepMounted
open={Boolean(anchorEl.value)}
onClose={handleMenuClose}
PaperProps={{
style: {
width: "250px",
},
}}
>
<MenuItem>
<ObjectFitButton />
</MenuItem>
<MenuItem>
<PictureInPictureButton />
</MenuItem>
</Menu>
</>
);
};

View File

@ -7,6 +7,7 @@ timelineActions: TimelineAction[]
progress: number progress: number
containerRef: any containerRef: any
seekTo: (time: number)=> void seekTo: (time: number)=> void
isVideoPlayerSmall: boolean
} }
@ -17,7 +18,7 @@ const placementStyles: Record<NonNullable<TimelineAction['placement']>, React.CS
'BOTTOM-RIGHT': { bottom: 60, right: 16 }, 'BOTTOM-RIGHT': { bottom: 60, right: 16 },
}; };
export const TimelineActionsComponent = ({timelineActions, progress, containerRef, seekTo}: TimelineActionsComponentProps) => { export const TimelineActionsComponent = ({timelineActions, progress, containerRef, seekTo, isVideoPlayerSmall}: TimelineActionsComponentProps) => {
const [isOpen, setIsOpen] = useState(true) const [isOpen, setIsOpen] = useState(true)
const handleClick = useCallback((action: TimelineAction)=> { const handleClick = useCallback((action: TimelineAction)=> {
@ -60,7 +61,9 @@ export const TimelineActionsComponent = ({timelineActions, progress, containerRe
}} }}
> >
<Typography key={index} variant="body2" onClick={()=> handleClick(action)}> <Typography key={index} sx={{
fontSize: isVideoPlayerSmall ? '16px' : '18px'
}} onClick={()=> handleClick(action)}>
{action.label} {action.label}
</Typography> </Typography>

View File

@ -289,6 +289,9 @@ export const VideoTime = ({ progress, isScreenSmall, duration }: any) => {
title="Seek video in 10% increments (0-9)" title="Seek video in 10% increments (0-9)"
placement="bottom" placement="bottom"
arrow arrow
disableHoverListener={isScreenSmall}
disableFocusListener={isScreenSmall}
disableTouchListener={isScreenSmall}
> >
<Typography <Typography
sx={{ sx={{
@ -296,7 +299,7 @@ export const VideoTime = ({ progress, isScreenSmall, duration }: any) => {
color: "white", color: "white",
visibility: typeof duration !== "number" ? "hidden" : "visible", visibility: typeof duration !== "number" ? "hidden" : "visible",
whiteSpace: "nowrap", whiteSpace: "nowrap",
fontFamily: "sans-serif" fontFamily: "sans-serif",
}} }}
> >
{typeof duration === "number" ? formatTime(progress) : ""} {typeof duration === "number" ? formatTime(progress) : ""}

View File

@ -1,6 +1,5 @@
import { Box, IconButton } from "@mui/material"; import { Box, IconButton } from "@mui/material";
import { ControlsContainer } from "./VideoPlayer-styles"; import { ControlsContainer } from "./VideoPlayer-styles";
// import { MobileControlsBar } from "./MobileControlsBar";
import { import {
FullscreenButton, FullscreenButton,
ObjectFitButton, ObjectFitButton,
@ -80,7 +79,6 @@ export const VideoControlsBar = ({subtitleBtnRef, setLocalProgress, showControls
> >
{showMobileControls ? ( {showMobileControls ? (
null null
// <MobileControlsBar />
) : canPlay ? ( ) : canPlay ? (
<Box sx={{ <Box sx={{
display: 'flex', display: 'flex',

View File

@ -148,7 +148,7 @@ export const VideoPlayer = ({
const playerRef = useRef<Player | null>(null); const playerRef = useRef<Player | null>(null);
const [drawerOpenSubtitles, setDrawerOpenSubtitles] = useState(false); const [drawerOpenSubtitles, setDrawerOpenSubtitles] = useState(false);
const [drawerOpenPlayback, setDrawerOpenPlayback] = useState(false); const [drawerOpenPlayback, setDrawerOpenPlayback] = useState(false);
const [showControlsMobile, setShowControlsMobile] = useState(false); const [showControlsMobile2, setShowControlsMobile] = useState(false);
const [isPlayerInitialized, setIsPlayerInitialized] = useState(false); const [isPlayerInitialized, setIsPlayerInitialized] = useState(false);
const [videoCodec, setVideoCodec] = useState<null | false | string>(null); const [videoCodec, setVideoCodec] = useState<null | false | string>(null);
const [isMuted, setIsMuted] = useState(false); const [isMuted, setIsMuted] = useState(false);
@ -201,6 +201,8 @@ export const VideoPlayer = ({
videoRef, videoRef,
}); });
const showControlsMobile = (showControlsMobile2 || !isPlaying) && isVideoPlayerSmall
useEffect(() => { useEffect(() => {
if (location) { if (location) {
locationRef.current = location.pathname; locationRef.current = location.pathname;
@ -920,6 +922,7 @@ export const VideoPlayer = ({
containerRef={containerRef} containerRef={containerRef}
progress={localProgress} progress={localProgress}
timelineActions={timelineActions} timelineActions={timelineActions}
isVideoPlayerSmall={isVideoPlayerSmall}
/> />
)} )}
{showControlsMobile && isReady && ( {showControlsMobile && isReady && (