mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-06 08:04:37 +00:00
fix(video): resolve 1-frame shift on external seeks due to floor rounding
This commit is contained in:
@@ -245,7 +245,7 @@ export function useFramePlayer(
|
|||||||
const handleExternalSeeked = () => {
|
const handleExternalSeeked = () => {
|
||||||
// Only sync if this seek was not triggered internally by seekToFrame
|
// Only sync if this seek was not triggered internally by seekToFrame
|
||||||
if (!isSeekingRef.current) {
|
if (!isSeekingRef.current) {
|
||||||
const actualFrame = Math.floor(video.currentTime * frameRate)
|
const actualFrame = Math.round(video.currentTime * frameRate)
|
||||||
const finalFrame = Math.max(0, Math.min(actualFrame, totalFrames - 1))
|
const finalFrame = Math.max(0, Math.min(actualFrame, totalFrames - 1))
|
||||||
setCurrentFrame(finalFrame)
|
setCurrentFrame(finalFrame)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -903,7 +903,6 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
|||||||
toggleLoop={toggleLoop}
|
toggleLoop={toggleLoop}
|
||||||
toggleMute={toggleMute}
|
toggleMute={toggleMute}
|
||||||
handleVolumeChange={handleVolumeChange}
|
handleVolumeChange={handleVolumeChange}
|
||||||
setState={setState}
|
|
||||||
changePlaybackRate={changePlaybackRate}
|
changePlaybackRate={changePlaybackRate}
|
||||||
changeResolution={changeResolution}
|
changeResolution={changeResolution}
|
||||||
handleDownload={handleDownload}
|
handleDownload={handleDownload}
|
||||||
|
|||||||
Reference in New Issue
Block a user