Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit

Permalink
Merge branch 'autoplay-videos' into 'main'
Browse files Browse the repository at this point in the history
Autoplay videos

See merge request soapbox-pub/soapbox!3326
  • Loading branch information
alexgleason committed Feb 6, 2025
2 parents 848ea94 + f1beb34 commit 6668712
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/features/video/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ const Video: React.FC<IVideo> = ({

const [currentTime, setCurrentTime] = useState(0);
const [duration, setDuration] = useState(0);
const [volume, setVolume] = useState(0.5);
const [preVolume, setPreVolume] = useState(0);
const [volume, setVolume] = useState(0);
const [preVolume, setPreVolume] = useState(1);
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 [volumeHovered, setVolumeHovered] = useState(false);
const [seekHovered, setSeekHovered] = useState(false);
const [muted, setMuted] = useState(false);
const [muted, setMuted] = useState(true);
const [buffer, setBuffer] = useState(0);

const setDimensions = () => {
Expand Down Expand Up @@ -552,6 +552,7 @@ const Video: React.FC<IVideo> = ({
src={src}
loop
role='button'
autoPlay
tabIndex={0}
aria-label={alt}
title={alt}
Expand All @@ -569,6 +570,7 @@ const Video: React.FC<IVideo> = ({
onLoadedData={handleLoadedData}
onProgress={handleProgress}
onVolumeChange={handleVolumeChange}
muted={muted}
/>

<div
Expand Down Expand Up @@ -645,11 +647,11 @@ const Video: React.FC<IVideo> = ({
transform: 'translateY(-50%)',
}}
/>
<div className={clsx('absolute left-0 top-1/2 block h-1 -translate-y-1/2 rounded-md bg-accent-500', { 'bottom-[27px]': fullscreen || detailed })} style={{ width: `${volume * 100}%` }} />
<div className={clsx('absolute left-0 top-1/2 block h-1 -translate-y-1/2 rounded-md bg-accent-500', { 'bottom-[27px]': fullscreen || detailed })} style={{ width: `${muted ? 0 : volume * 100}%` }} />
<span
className={clsx('absolute left-0 top-1/2 z-30 -ml-1.5 size-3 -translate-y-1/2 rounded-full bg-accent-500 opacity-0 shadow-[1px_2px_6px_rgba(0,0,0,0.3)] transition-opacity duration-100', { 'opacity-100': volumeHovered, 'bottom-[23px]': fullscreen || detailed })}
tabIndex={0}
style={{ left: `${volume * 100}%` }}
style={{ left: `${muted ? 0 : volume * 100}%` }}
/>
</div>

Expand Down

0 comments on commit 6668712

Please sign in to comment.