Skip to content

Commit

Permalink
fix: added playlist button
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-1995 committed Feb 27, 2024
1 parent 5da6d47 commit 40d2d94
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { MouseEvent } from 'react';
import { PauseIcon, PlayIcon } from '@100mslive/react-icons';
import { IconButton, Tooltip } from '../../..';
import { useHMSPlayerContext } from './PlayerContext';

export const PlayButton = ({
isPaused,
width = 20,
height = 20,
}: {
isPaused: boolean;
width: number;
height: number;
}) => {
const { hlsPlayer } = useHMSPlayerContext();
const onClick = async (event: MouseEvent) => {
event?.stopPropagation();
isPaused ? await hlsPlayer?.play() : hlsPlayer?.pause();
};
return (
<Tooltip title={isPaused ? 'Play' : 'Pause'} side="top">
<IconButton onClick={onClick} data-testid="play_pause_btn">
{isPaused ? <PlayIcon width={width} height={height} /> : <PauseIcon width={width} height={height} />}
</IconButton>
</Tooltip>
);
};

0 comments on commit 40d2d94

Please sign in to comment.