Skip to content

Commit

Permalink
Fix clock inconsistency when changing language
Browse files Browse the repository at this point in the history
  • Loading branch information
killergerbah committed Feb 19, 2024
1 parent aff5a3e commit 036e83b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions common/app/components/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ export default function VideoPlayer({
forceRender({});
}, [playerChannel]);

const onErrorRef = useRef(onError);
onErrorRef.current = onError;

const videoRefCallback = useCallback(
(element: HTMLVideoElement) => {
if (element) {
Expand All @@ -417,14 +420,14 @@ export default function VideoPlayer({
};

videoElement.ontimeupdate = (event) => clock.setTime(element.currentTime * 1000);
videoElement.onerror = (event) => onError(errorMessage(element));
videoElement.onerror = (event) => onErrorRef.current?.(errorMessage(element));
videoElement.onplay = updatePlayerState;
videoElement.onpause = updatePlayerState;
videoElement.onratechange = updatePlayerState;
videoElement.onseeked = updatePlayerState;
}
},
[clock, playerChannel, updatePlayerState, onError]
[clock, playerChannel, updatePlayerState]
);

function selectAudioTrack(id: string) {
Expand Down

0 comments on commit 036e83b

Please sign in to comment.