Skip to content

Commit bebdbbd

Browse files
Add isPlaying status and handle map to simulation time (no playback controls)
1 parent 9222370 commit bebdbbd

3 files changed

Lines changed: 37 additions & 21 deletions

File tree

public/locales/en/components.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@
192192
},
193193
"info-box": {
194194
"description": "Properties for controlling video playback."
195-
}
195+
},
196+
"mapped-to-time-info": "Video playback is mapped to simulation time."
196197
}
197198
},
198199
"qrcode": {

src/components/PropertyOwner/Custom/VideoPlayer/VideoPlayer.tsx

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Grid,
66
Group,
77
MantineStyleProps,
8+
Paper,
89
Text,
910
ThemeIcon,
1011
Tooltip
@@ -22,8 +23,11 @@ import {
2223
RepeatOffIcon,
2324
ReplayIcon,
2425
SoundIcon,
25-
SoundOffIcon
26+
SoundOffIcon,
27+
TimeIcon
2628
} from '@/icons/icons';
29+
import styles from '@/theme/global.module.css';
30+
import { IconSize } from '@/types/enums';
2731
import { Uri } from '@/types/types';
2832

2933
interface Props extends MantineStyleProps {
@@ -55,10 +59,28 @@ export function VideoPlayer({ uri, ...styleProps }: Props) {
5559
playAudioUri
5660
);
5761

62+
const [isPlaying] = useProperty('BoolProperty', `${uri}.IsPlaying`);
63+
const [startTime] = useProperty('StringProperty', `${uri}.StartTime`);
64+
const [endTime] = useProperty('StringProperty', `${uri}.EndTime`);
65+
5866
if (!propertyOwner) {
5967
throw Error(`No property owner found for uri: ${uri}`);
6068
}
6169

70+
if (startTime || endTime) {
71+
// This video player is mapped to time, so don't show the playback controls
72+
return (
73+
<Paper ml={'xs'} p={'xs'}>
74+
<Group wrap={'nowrap'} gap={'xs'}>
75+
<ThemeIcon variant={'subtle'} size={'xs'}>
76+
<TimeIcon size={IconSize.xs} />
77+
</ThemeIcon>
78+
<Text size={'sm'}>{t('mapped-to-time-info')}</Text>
79+
</Group>
80+
</Paper>
81+
);
82+
}
83+
6284
// Data for the different properties that the controls represent, to show in the
6385
// info box
6486
const propertyData = [
@@ -76,24 +98,17 @@ export function VideoPlayer({ uri, ...styleProps }: Props) {
7698
return (
7799
<Group pl={'xs'} wrap={'nowrap'} {...styleProps}>
78100
<Group gap={'xs'} py={'xs'}>
79-
<ActionIcon.Group>
80-
<Tooltip label={t('play-button.tooltip')}>
81-
<ActionIcon
82-
onClick={() => triggerPlay(null)}
83-
aria-label={t('play-button.aria-label')}
84-
>
85-
<PlayIcon />
86-
</ActionIcon>
87-
</Tooltip>
88-
<Tooltip label={t('pause-button.tooltip')}>
89-
<ActionIcon
90-
onClick={() => triggerPause(null)}
91-
aria-label={t('pause-button.aria-label')}
92-
>
93-
<PauseIcon />
94-
</ActionIcon>
95-
</Tooltip>
96-
</ActionIcon.Group>
101+
<Tooltip label={isPlaying ? t('pause-button.tooltip') : t('play-button.tooltip')}>
102+
<ActionIcon
103+
variant={isPlaying ? 'filled' : 'default'}
104+
onClick={() => (isPlaying ? triggerPause(null) : triggerPlay(null))}
105+
aria-label={
106+
isPlaying ? t('pause-button.aria-label') : t('play-button.aria-label')
107+
}
108+
>
109+
{isPlaying ? <PauseIcon className={styles.blinking} /> : <PlayIcon />}
110+
</ActionIcon>
111+
</Tooltip>
97112
<Tooltip label={t('restart-button.tooltip')}>
98113
<ActionIcon
99114
onClick={() => triggerGoToStart(null)}

src/icons/icons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export {
2727
export { GoBrowser as BrowserIcon } from 'react-icons/go';
2828
export { GoMoveToEnd as GoToEnd, GoMoveToStart as GoToStart } from 'react-icons/go';
2929
export { ImSphere as GridSphereIcon } from 'react-icons/im';
30-
export { IoMdGlobe as GlobeIcon } from 'react-icons/io';
30+
export { IoMdGlobe as GlobeIcon, IoMdTime as TimeIcon } from 'react-icons/io';
3131
export {
3232
IoInformationCircleOutline as InformationCircleOutlineIcon,
3333
IoInformation as InformationIcon,

0 commit comments

Comments
 (0)