mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 08:46:53 +00:00
fix(webui): snap playhead to last frame upon ended event in useFramePlayer
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user