diff --git a/src/features/video/index.tsx b/src/features/video/index.tsx index 27efd8a2c..028c1188a 100644 --- a/src/features/video/index.tsx +++ b/src/features/video/index.tsx @@ -5,7 +5,7 @@ import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from import { defineMessages, useIntl } from 'react-intl'; import Blurhash from 'soapbox/components/blurhash'; -import Icon from 'soapbox/components/icon'; +import SvgIcon from 'soapbox/components/ui/icon/svg-icon'; import { isPanoramic, isPortrait, minimumAspectRatio, maximumAspectRatio } from 'soapbox/utils/media-aspect-ratio'; import { isFullscreen, requestFullscreen, exitFullscreen } from '../ui/util/fullscreen'; @@ -138,11 +138,13 @@ const Video: React.FC = ({ const [currentTime, setCurrentTime] = useState(0); const [duration, setDuration] = useState(0); const [volume, setVolume] = useState(0.5); + const [preVolume, setPreVolume] = useState(0); const [paused, setPaused] = useState(true); const [dragging, setDragging] = useState(false); const [containerWidth, setContainerWidth] = useState(width); const [fullscreen, setFullscreen] = useState(false); const [hovered, setHovered] = useState(false); + const [seekHovered, setSeekHovered] = useState(false); const [muted, setMuted] = useState(false); const [buffer, setBuffer] = useState(0); @@ -387,12 +389,28 @@ const Video: React.FC = ({ const handleMouseLeave = () => { setHovered(false); }; + const handleSeekEnter = () => { + setSeekHovered(true); + }; + + const handleSeekLeave = () => { + setSeekHovered(false); + }; const toggleMute = () => { if (video.current) { const muted = !video.current.muted; setMuted(!muted); video.current.muted = muted; + + if (muted) { + setPreVolume(video.current.volume); + video.current.volume = 0; + setVolume(0); + } else { + video.current.volume = preVolume; + setVolume(preVolume); + } } }; @@ -463,17 +481,15 @@ const Video: React.FC = ({ return (
{!fullscreen && ( - + )}