fix(webui): snap playhead to last frame upon ended event in useFramePlayer

This commit is contained in:
yiling
2026-07-10 16:35:41 +08:00
parent 9414ebaefd
commit 55457fcd36
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ const tempImgPath = path.resolve(currentDir, 'temp-cover.png')
test.beforeAll(async () => {
// Create a 1x1 transparent PNG file
const pngBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
const pngBase64 =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
fs.writeFileSync(tempImgPath, Buffer.from(pngBase64, 'base64'))
})
@@ -186,8 +186,13 @@ export function useFramePlayer(
}
}
const handleEnded = () => {
setCurrentFrame(totalFrames - 1)
}
video.addEventListener('play', handlePlay)
video.addEventListener('pause', handlePause)
video.addEventListener('ended', handleEnded)
// If it's already playing when this effect runs
if (!video.paused) {
@@ -199,6 +204,7 @@ export function useFramePlayer(
active = false
video.removeEventListener('play', handlePlay)
video.removeEventListener('pause', handlePause)
video.removeEventListener('ended', handleEnded)
if (rVfcId !== null) {
const videoWithCallback = video as unknown as HtmlVideoElementWithCallback
if (videoWithCallback.cancelVideoFrameCallback) {