diff --git a/src/view/com/util/post-embeds/VideoEmbedInner/TimeIndicator.tsx b/src/view/com/util/post-embeds/VideoEmbedInner/TimeIndicator.tsx index 6636883f12..475c25fefc 100644 --- a/src/view/com/util/post-embeds/VideoEmbedInner/TimeIndicator.tsx +++ b/src/view/com/util/post-embeds/VideoEmbedInner/TimeIndicator.tsx @@ -1,4 +1,5 @@ import React from 'react' +import {StyleProp, ViewStyle} from 'react-native' import Animated, {FadeInDown, FadeOutDown} from 'react-native-reanimated' import {atoms as a, native, useTheme} from '#/alf' @@ -8,7 +9,13 @@ import {Text} from '#/components/Typography' * Absolutely positioned time indicator showing how many seconds are remaining * Time is in seconds */ -export function TimeIndicator({time}: {time: number}) { +export function TimeIndicator({ + time, + style, +}: { + time: number + style?: StyleProp +}) { const t = useTheme() if (isNaN(time)) { @@ -22,18 +29,20 @@ export function TimeIndicator({time}: {time: number}) { { + function listener(newIsPlaying: boolean) { + setIsPlaying(newIsPlaying) + } + player.addListener('playingChange', listener) + return () => { + player.removeListener('playingChange', listener) + } + }, [player]) const onPressFullscreen = useCallback(() => { switch (player.status) { @@ -116,6 +131,15 @@ function VideoControls({ } }, [player, enterFullscreen]) + const togglePlayPause = useCallback(() => { + setIsPlaying(!player.playing) + if (player.playing) { + player.pause() + } else { + player.play() + } + }, [player]) + const toggleMuted = useCallback(() => { const muted = !player.muted // We want to set this to the _inverse_ of the new value, because we actually want for the audio to be mixed when @@ -137,7 +161,6 @@ function VideoControls({ return ( - {showTime && } - - - {isMuted ? ( - + {autoplayDisabled && ( + + {isPlaying ? ( + ) : ( - + )} - - + + )} + {showTime && ( + + )} + + + {isMuted ? ( + + ) : ( + + )} + ) } + +function ControlButton({ + onPress, + children, + label, + accessibilityHint, + style, +}: { + onPress: () => void + children: React.ReactNode + label: string + accessibilityHint: string + style?: StyleProp +}) { + return ( + + + {children} + + + ) +}