mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 23:24:21 +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 () => {
|
test.beforeAll(async () => {
|
||||||
// Create a 1x1 transparent PNG file
|
// Create a 1x1 transparent PNG file
|
||||||
const pngBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
|
const pngBase64 =
|
||||||
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
|
||||||
fs.writeFileSync(tempImgPath, Buffer.from(pngBase64, 'base64'))
|
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('play', handlePlay)
|
||||||
video.addEventListener('pause', handlePause)
|
video.addEventListener('pause', handlePause)
|
||||||
|
video.addEventListener('ended', handleEnded)
|
||||||
|
|
||||||
// If it's already playing when this effect runs
|
// If it's already playing when this effect runs
|
||||||
if (!video.paused) {
|
if (!video.paused) {
|
||||||
@@ -199,6 +204,7 @@ export function useFramePlayer(
|
|||||||
active = false
|
active = false
|
||||||
video.removeEventListener('play', handlePlay)
|
video.removeEventListener('play', handlePlay)
|
||||||
video.removeEventListener('pause', handlePause)
|
video.removeEventListener('pause', handlePause)
|
||||||
|
video.removeEventListener('ended', handleEnded)
|
||||||
if (rVfcId !== null) {
|
if (rVfcId !== null) {
|
||||||
const videoWithCallback = video as unknown as HtmlVideoElementWithCallback
|
const videoWithCallback = video as unknown as HtmlVideoElementWithCallback
|
||||||
if (videoWithCallback.cancelVideoFrameCallback) {
|
if (videoWithCallback.cancelVideoFrameCallback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user