Skip to content

Commit

Permalink
Always show media player bottom controls (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhons authored Aug 2, 2024
1 parent aa80de7 commit ca5dc4e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 338 deletions.
311 changes: 0 additions & 311 deletions src/components/media-player/__test__/MediaPlayer.spec.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Grid from '@mui/material/Grid';
import { FC, memo, ReactNode } from 'react';

import { useIsAudio, usePlayPauseReplayHook } from '../../../hooks';
import { useIsAudio } from '../../../hooks';
import { BOTTOM_CONTROL_BUTTONS } from '../../../utils';
import { useBottomControlButtonsHook } from '../../bottom-control-buttons/useBottomControlButtonsHook';
import { useBottomControlButtonsStyles } from '../../bottom-control-buttons/useBottomControlButtonsStyles';
Expand All @@ -28,12 +28,9 @@ export const MediaPlayerControlButtons: FC<MediaPlayerControlButtonsProps> =
}) => {
const isAudio = useIsAudio();
const { classes, cx } = useBottomControlButtonsStyles();
const { hasStarted, showControls } = useBottomControlButtonsHook();
const { isFinished } = usePlayPauseReplayHook();
const { showControls } = useBottomControlButtonsHook();

const hide = isCollapsed
? !hasStarted || isFinished
: (!showControls || !hasStarted) && !isAudio;
const hide = !isCollapsed && !showControls && !isAudio;

if (hide) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
} from '../../bottom-control-buttons';
import { CollapseIconButton } from '../../bottom-control-buttons/components/CollapseIconButton';
import { BottomControls } from '../../bottom-controls/BottomControls';
import { CenteredPlayButton } from '../../centered-play-button/CenteredPlayButton';
import { CenteredReplayButton } from '../../centered-replay-button/CenteredReplayButton';
import { useControlsStyles, Controls } from '../../controls';
import { PauseAnimation } from '../../play-pause-animation/PauseAnimation';
import { PlayAnimation } from '../../play-pause-animation/PlayAnimation';
Expand Down Expand Up @@ -70,10 +68,6 @@ export const MediaPlayerControls: FC<MediaPlayerControlsProps> = memo(
<AdditionalControls />
</>
)}
<Grid className={controls}>
<CenteredPlayButton />
<CenteredReplayButton />
</Grid>
<BottomControls>
<MediaPlayerControlButtons isCollapsed={isCollapsed}>
<ProgressTimerDisplay />
Expand Down
24 changes: 9 additions & 15 deletions src/components/progress-bar/ProgressTimerDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ export const ProgressTimerDisplay: FC<ProgressTimerDisplayProps> = ({
classes: { timeStampText },
} = useTimeDisplayStyles();

const [hasStarted, duration, setCurrentTime, isPip, currentTime] =
useMediaStore(
state => [
state.hasPlayedOrSeeked,
state.duration,
state.setCurrentTime,
state.isPip,
state.currentTime,
],
shallow,
);
const [duration, setCurrentTime, isPip, currentTime] = useMediaStore(
state => [
state.duration,
state.setCurrentTime,
state.isPip,
state.currentTime,
],
shallow,
);

const onCurrentTimeUpdate = (e: Event, newValue: number | number[]) => {
e.preventDefault();
Expand All @@ -62,10 +60,6 @@ export const ProgressTimerDisplay: FC<ProgressTimerDisplayProps> = ({
cx,
} = useProgressBarStyles({ isAudio, isPip });

if (!hasStarted && !isAudio) {
return null;
}

return (
<Grid
container
Expand Down

0 comments on commit ca5dc4e

Please sign in to comment.