Skip to content

Commit 14648a3

Browse files
committed
Make ForceSyncVideo work more reliably
- Make ForceSyncVideo seek the video back a bit before syncing to the correct time since the video players can have trouble seeking to exactly the right time if you're already very close to the target time
1 parent 3a03e72 commit 14648a3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Assets/USharpVideo/Scripts/USharpVideoPlayer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ public void ForceSyncVideo()
696696
float offsetTime = Mathf.Clamp((float)(GetNetworkTime() - _videoStartNetworkTime) + localSyncOffset, 0f, _videoPlayerManager.GetDuration());
697697
#endif
698698

699+
float syncNudgeTime = Mathf.Max(0f, offsetTime - 1f);
700+
_videoPlayerManager.SetTime(syncNudgeTime); // Seek to slightly earlier before syncing to the real time to get the video player to jump cleanly
699701
_videoPlayerManager.SetTime(offsetTime);
700702
LogMessage($"Syncing video to {offsetTime:N2}");
701703
}

0 commit comments

Comments
 (0)