import React, { useMemo } from 'react'; import { HMSPlaylistType, selectAudioPlaylist, selectAudioTrackVolume, selectPeerSharingVideoPlaylist, selectVideoPlaylist, selectVideoPlaylistAudioTrackByPeerID, } from '@100mslive/hms-video-store'; import { NextIcon, PauseIcon, PlayIcon, PrevIcon, VideoExitFullScreenIcon, VideoFullScreenIcon, VolumeIcon, } from '../Icons'; import { Button } from '../Button'; import { Slider } from '../Slider/Slider'; import { VideoPlaylist } from './VideoPlaylist'; import { Text } from '../Text'; import { useHMSActions, useHMSStore } from '../../hooks/HMSRoomProvider'; import { useHMSTheme } from '../../hooks/HMSThemeProvider'; import { hmsUiClassParserGenerator } from '../../utils/classes'; import { formatDuration } from '../../utils/timerUtils'; export interface PlaylistControlsClasses { root?: string; controlsContainer?: string; controls?: string; icon?: string; progress?: string; sliderContainer?: string; rightControls?: string; volumeControl?: string; volumeControlIcon?: string; } export interface PlaylistControlsProps { classes?: PlaylistControlsClasses; type?: HMSPlaylistType; toggleFullScreen?: () => void; isFullScreen?: boolean; } interface PlaylistProgressProps { styler: (s: keyof PlaylistControlsClasses) => string | undefined; type: HMSPlaylistType; duration?: number; } const defaultClasses: PlaylistControlsClasses = { root: 'h-16 flex flex-col', controlsContainer: 'flex justify-between', controls: 'px-3 flex-1 flex justify-center items-center', icon: 'w-full h-full', progress: 'flex items-center px-2 text-gray-500', sliderContainer: 'px-3 flex-1', rightControls: 'flex items-center px-2', volumeControl: 'flex items-center w-24 pl-2', volumeControlIcon: 'mr-2 fill-current text-gray-100 dark:text-white', }; const PlaylistProgress = ({ styler, type, duration, }: PlaylistProgressProps) => { const selectPlaylist = type === HMSPlaylistType.audio ? selectAudioPlaylist : selectVideoPlaylist; const progress = useHMSStore(selectPlaylist.progress); const hmsActions = useHMSActions(); const playlistAction = type === HMSPlaylistType.audio ? hmsActions.audioPlaylist : hmsActions.videoPlaylist; if (!duration) { return null; } return (