Skip to content

Commit

Permalink
Merge pull request #46795 from dominictb/fix/45277
Browse files Browse the repository at this point in the history
fix: update volume to 0.25 if unmute but volume is 0
  • Loading branch information
cristipaval authored Aug 9, 2024
2 parents ef3f178 + 44ff609 commit 7d9203b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ function BaseVideoPlayer({
[playVideo, videoResumeTryNumberRef],
);

const prevIsMutedRef = useRef(false);
const prevVolumeRef = useRef(0);

const handlePlaybackStatusUpdate = useCallback(
(status: AVPlaybackStatus) => {
if (!status.isLoaded) {
Expand All @@ -193,6 +196,16 @@ function BaseVideoPlayer({
onPlaybackStatusUpdate?.(status);
return;
}

if (prevIsMutedRef.current && prevVolumeRef.current === 0 && !status.isMuted) {
updateVolume(0.25);
}
if (isFullScreenRef.current && prevVolumeRef.current !== 0 && status.volume === 0 && !status.isMuted) {
currentVideoPlayerRef.current?.setStatusAsync({isMuted: true});
}
prevIsMutedRef.current = status.isMuted;
prevVolumeRef.current = status.volume;

const isVideoPlaying = status.isPlaying;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const currentDuration = status.durationMillis || videoDuration * 1000;
Expand Down

0 comments on commit 7d9203b

Please sign in to comment.