Fix: External video starting at wrong time

This commit is contained in:
André 2024-03-05 13:33:29 -03:00
parent a51e00c1e8
commit fa4d8ae091

View File

@ -37,6 +37,7 @@ import { EXTERNAL_VIDEO_UPDATE } from '../mutations';
import PeerTube from '../custom-players/peertube'; import PeerTube from '../custom-players/peertube';
import { ArcPlayer } from '../custom-players/arc-player'; import { ArcPlayer } from '../custom-players/arc-player';
import { is } from 'ramda';
const AUTO_PLAY_BLOCK_DETECTION_TIMEOUT_SECONDS = 5; const AUTO_PLAY_BLOCK_DETECTION_TIMEOUT_SECONDS = 5;
@ -288,6 +289,7 @@ const ExternalVideoPlayer: React.FC<ExternalVideoPlayerProps> = ({
} }
const rate = playerRef.current?.getInternalPlayer()?.getPlaybackRate() as number ?? 1; const rate = playerRef.current?.getInternalPlayer()?.getPlaybackRate() as number ?? 1;
const currentTime = playerRef.current?.getCurrentTime() ?? 0; const currentTime = playerRef.current?.getCurrentTime() ?? 0;
console.log(currentTime, 'currentTime');
sendMessage('play', { sendMessage('play', {
rate, rate,
time: currentTime, time: currentTime,
@ -505,13 +507,14 @@ const ExternalVideoPlayerContainer: React.FC = () => {
const currentDate = new Date(Date.now() + timeSync); const currentDate = new Date(Date.now() + timeSync);
const currentTime = (((currentDate.getTime() - playerUpdatedAtDate.getTime()) / 1000) const currentTime = (((currentDate.getTime() - playerUpdatedAtDate.getTime()) / 1000)
+ playerCurrentTime) * playerPlaybackRate; + playerCurrentTime) * playerPlaybackRate;
const isPresenter = currentUser.presenter ?? false;
return ( return (
<ExternalVideoPlayer <ExternalVideoPlayer
currentVolume={currentVolume} currentVolume={currentVolume}
isMuted={isMuted} isMuted={isMuted}
isEchoTest={isEchoTest} isEchoTest={isEchoTest}
isPresenter={currentUser.presenter ?? false} isPresenter={isPresenter ?? false}
videoUrl={currentMeeting.externalVideo?.externalVideoUrl ?? ''} videoUrl={currentMeeting.externalVideo?.externalVideoUrl ?? ''}
playing={currentMeeting.externalVideo?.playerPlaying ?? false} playing={currentMeeting.externalVideo?.playerPlaying ?? false}
playerPlaybackRate={currentMeeting.externalVideo?.playerPlaybackRate ?? 1} playerPlaybackRate={currentMeeting.externalVideo?.playerPlaybackRate ?? 1}
@ -519,7 +522,7 @@ const ExternalVideoPlayerContainer: React.FC = () => {
layoutContextDispatch={layoutContextDispatch} layoutContextDispatch={layoutContextDispatch}
fullscreenContext={fullscreenContext} fullscreenContext={fullscreenContext}
externalVideo={externalVideo} externalVideo={externalVideo}
currentTime={currentTime} currentTime={isPresenter ? playerCurrentTime : currentTime}
key={key} key={key}
setKey={setKey} setKey={setKey}
/> />