Skip to content

Commit

Permalink
Send second play event after a play event to adjust for video player …
Browse files Browse the repository at this point in the history
…issues
  • Loading branch information
dumdum7 authored Dec 29, 2024
1 parent a5f5110 commit c768124
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ui/v2.5/src/components/ScenePlayer/ScenePlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,19 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
const player = getPlayer();
if (!player) return;

// delay before second play event after a play event to adjust for video player issues
const DELAY_FOR_SECOND_PLAY_MS = 1000;
let playingTimer: number;

function playing(this: VideoJsPlayer) {
if (scene.interactive && interactiveReady.current) {
interactiveClient.play(this.currentTime());
// trigger a second script play event to adjust for video player issues
clearTimeout(playingTimer);
playingTimer = setTimeout(() => {
if (this.paused()) return;
interactiveClient.play(this.currentTime());
}, DELAY_FOR_SECOND_PLAY_MS);
}
}

Expand All @@ -522,6 +532,7 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
player.off("playing", playing);
player.off("pause", pause);
player.off("timeupdate", timeupdate);
clearTimeout(playingTimer);
};
}, [getPlayer, interactiveClient, scene]);

Expand Down

0 comments on commit c768124

Please sign in to comment.