diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-09-16 22:22:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 14:22:22 -0700 |
commit | 8daf6b78688ca20326a79fa9c7ca1cbd945786e1 (patch) | |
tree | 3820eab34b90917acf8faaeb725cc5a51298bd71 /src/view/com/util/post-embeds/VideoEmbedInner/web-controls/utils.tsx | |
parent | 8241747fc22bb4363ff6cf48d54013cc72db7624 (diff) | |
download | voidsky-8daf6b78688ca20326a79fa9c7ca1cbd945786e1.tar.zst |
[Video] Fix safari showing spinner (#5364)
Diffstat (limited to 'src/view/com/util/post-embeds/VideoEmbedInner/web-controls/utils.tsx')
-rw-r--r-- | src/view/com/util/post-embeds/VideoEmbedInner/web-controls/utils.tsx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/view/com/util/post-embeds/VideoEmbedInner/web-controls/utils.tsx b/src/view/com/util/post-embeds/VideoEmbedInner/web-controls/utils.tsx index aa1b0b8cd..8aa2d3f7d 100644 --- a/src/view/com/util/post-embeds/VideoEmbedInner/web-controls/utils.tsx +++ b/src/view/com/util/post-embeds/VideoEmbedInner/web-controls/utils.tsx @@ -1,5 +1,6 @@ import React, {useCallback, useEffect, useRef, useState} from 'react' +import {isSafari} from '#/lib/browser' import {useVideoVolumeState} from '../../VideoVolumeContext' export function useVideoElement(ref: React.RefObject<HTMLVideoElement>) { @@ -37,6 +38,12 @@ export function useVideoElement(ref: React.RefObject<HTMLVideoElement>) { const handleTimeUpdate = () => { if (!ref.current) return setCurrentTime(round(ref.current.currentTime) || 0) + // HACK: Safari randomly fires `stalled` events when changing between segments + // let's just clear the buffering state if the video is still progressing -sfn + if (isSafari) { + if (bufferingTimeout) clearTimeout(bufferingTimeout) + setBuffering(false) + } } const handleDurationChange = () => { @@ -82,7 +89,7 @@ export function useVideoElement(ref: React.RefObject<HTMLVideoElement>) { if (bufferingTimeout) clearTimeout(bufferingTimeout) bufferingTimeout = setTimeout(() => { setBuffering(true) - }, 200) // Delay to avoid frequent buffering state changes + }, 500) // Delay to avoid frequent buffering state changes } const handlePlaying = () => { @@ -95,7 +102,7 @@ export function useVideoElement(ref: React.RefObject<HTMLVideoElement>) { if (bufferingTimeout) clearTimeout(bufferingTimeout) bufferingTimeout = setTimeout(() => { setBuffering(true) - }, 200) // Delay to avoid frequent buffering state changes + }, 500) // Delay to avoid frequent buffering state changes } const handleEnded = () => { |