Skip to content
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

Player improvements #394

Merged
merged 5 commits into from
Jun 12, 2024
Merged
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
1 change: 1 addition & 0 deletions src/stories/player/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const PlayerCore = forwardRef<HTMLVideoElement, PlayerArgs>(
) : (
<FloatingControls
isPlaying={context.isPlaying}
showControls={props.showControls}
onClick={togglePlay}
/>
)}
Expand Down
30 changes: 30 additions & 0 deletions src/stories/player/parts/CutStart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { styled } from "styled-components";

const Pin = styled.div<{ left: number }>`
width: 2px;
bottom: 0;
left: ${({ left }) => `${left}%`};
position: absolute;
height: 250%;
z-index: 2;
background-color: ${({ theme }) => theme.palette.grey[600]};
margin-left: -2px; // To not override the current time marker

&:after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
width: 10px;
height: 10px;
border-radius: 50%;
transform: translate(-50%, 0);
background-color: ${({ theme }) => theme.palette.grey[600]};
}
`;

const CutStart = ({ left }: { left: number; }) => {
return <Pin id="obs-start-pin" left={left} />;
};

export { CutStart };
4 changes: 3 additions & 1 deletion src/stories/player/parts/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { VideoStyle } from "./video";

export const Container = styled.div<WrapperProps>`
position: relative;
${({ showControls }) => !showControls && `
${({ showControls }) => !showControls ? `
display: flex;
flex-direction: column;
justify-content: center;
`: `
margin-bottom: 80px;
`}
height: 100%;
width: 100%;
Expand Down
12 changes: 11 additions & 1 deletion src/stories/player/parts/controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { TimeLabel } from "./timeLabel";
import { PlayerTooltip } from "./tooltip";
import { formatDuration } from "../utils";
import useDebounce from "../../../hooks/useDebounce";
import { CutStart } from "./CutStart";

export const ControlsWrapper = styled.div<WrapperProps>`
${({ showControls }) => showControls ? "position: relative;" : "position: absolute;"}
Expand Down Expand Up @@ -85,6 +86,7 @@ export const Controls = ({
const progressRef = useRef<HTMLDivElement>(null);
const { context, setCurrentTime } = useVideoContext()
const debouncedMark = useDebounce(updatedMark, 500);
const [cutStart, setCutStart] = useState<number>(0);

const { reset, isGrabbing, activeBookmark, fromEnd } = useProgressContext();

Expand Down Expand Up @@ -197,6 +199,13 @@ export const Controls = ({
}
}, [debouncedMark, onBookMarkUpdated]);

useEffect(() => {
if (isCutting) {
setCutStart(progress);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isCutting]);

return (
<ControlsWrapper
showControls={showControls}
Expand All @@ -219,7 +228,8 @@ export const Controls = ({
progress={progress}
handleSkipAhead={handleSkipAhead}
duration={duration}
/>
/>
{isCutting && <CutStart left={cutStart} />}
<CurrentTimeMarker left={progress} />
</ProgressContainer>

Expand Down
9 changes: 5 additions & 4 deletions src/stories/player/parts/floatingControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export const FloatingContainer = styled.div<WrapperProps>`
top: 0;
left: 0;
right: 0;
${({ isPlaying }) => isPlaying && "display: none;"}
z-index: 1;
height: calc(100% - 80px);
${({ isPlaying }) => isPlaying && "display: none;"}
${({ showControls }) => showControls ? "height: 100%" : "height: calc(100% - 80px)"};
`;

const PlayIcon = styled(PlayIconComponent)``;
Expand Down Expand Up @@ -40,12 +40,13 @@ const ButtonsContainer = styled.div`

export const FloatingControls = (props: {
isPlaying?: boolean;
showControls?: boolean;
onClick?: () => void;
}) => {
const { isPlaying, onClick } = props;
const { isPlaying, showControls, onClick } = props;

return (
<FloatingContainer isPlaying={isPlaying} onClick={onClick}>
<FloatingContainer isPlaying={isPlaying} showControls={showControls} onClick={onClick}>
<ButtonsContainer>
{!isPlaying && (
<BigButton isPrimary size={"large"}>
Expand Down
Loading