fix(playback-store): reset playhead and notify video elements on completion
This commit is contained in:
@ -21,7 +21,13 @@ const startTimer = (store: any) => {
|
|||||||
|
|
||||||
const newTime = state.currentTime + delta * state.speed;
|
const newTime = state.currentTime + delta * state.speed;
|
||||||
if (newTime >= state.duration) {
|
if (newTime >= state.duration) {
|
||||||
|
// When video completes, pause and reset playhead to start
|
||||||
state.pause();
|
state.pause();
|
||||||
|
state.setCurrentTime(0);
|
||||||
|
// Notify video elements to sync with reset
|
||||||
|
window.dispatchEvent(
|
||||||
|
new CustomEvent("playback-seek", { detail: { time: 0 } })
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
state.setCurrentTime(newTime);
|
state.setCurrentTime(newTime);
|
||||||
// Notify video elements to sync
|
// Notify video elements to sync
|
||||||
|
Reference in New Issue
Block a user