mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 02:19:28 +00:00
fix(video): add centralized playhead nudge for boundary-accurate seeking
This commit is contained in:
@@ -248,6 +248,13 @@ export function useFramePlayer(
|
||||
const actualFrame = Math.round(video.currentTime * frameRate)
|
||||
const finalFrame = Math.max(0, Math.min(actualFrame, totalFrames - 1))
|
||||
setCurrentFrame(finalFrame)
|
||||
|
||||
// Nudge to safe frame center to guarantee correct browser decoding
|
||||
const frameDuration = 1 / frameRate
|
||||
const safeCenterTime = finalFrame * frameDuration + frameDuration / 2
|
||||
if (Math.abs(video.currentTime - safeCenterTime) > frameDuration / 4) {
|
||||
video.currentTime = safeCenterTime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user