From bef03ff1206a63ee1417ccbb841fbf42da84ac76 Mon Sep 17 00:00:00 2001 From: Rakov Date: Mon, 14 Aug 2023 14:36:42 +0300 Subject: [PATCH] fix(#ios): ios player fix --- src/features/StreamPlayer/hooks/index.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/features/StreamPlayer/hooks/index.tsx b/src/features/StreamPlayer/hooks/index.tsx index e3a764ca..b107383a 100644 --- a/src/features/StreamPlayer/hooks/index.tsx +++ b/src/features/StreamPlayer/hooks/index.tsx @@ -202,19 +202,22 @@ export const useVideoPlayer = ({ const chaptersDuration = useDuration(chapters) - const duration = useMemo(() => (( - isLive - && chapters[0]?.isFullMatchChapter - && Number.isFinite(videoRefDurationMs) - ) - ? videoRefDurationMs - getActiveChapter().startOffsetMs - : chaptersDuration - ), [ + const duration = useMemo(() => { + if (isLive && chapters[0]?.isFullMatchChapter) { + if (isIOS) { + return fullMatchDuration - getActiveChapter().startOffsetMs + } if (Number.isFinite(videoRefDurationMs)) { + return videoRefDurationMs - getActiveChapter().startOffsetMs + } + } + return chaptersDuration + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [ chapters, chaptersDuration, + fullMatchDuration, getActiveChapter, isLive, - videoRefDurationMs, ]) const { @@ -688,7 +691,7 @@ export const useVideoPlayer = ({ buffering, chapters, currentPlayingOrder, - duration: duration || videoRefDurationMs, + duration, isFirstChapterPlaying, isFullscreen, isLastChapterPlaying,