impl auto play

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent cae9f7652b
commit 750ed8b69e
5 changed files with 17 additions and 3 deletions

View File

@@ -175,11 +175,19 @@
onupdate({ changed, current, previous }) {
if (current.replayer && !previous) {
window.replayer = current.replayer;
// auto play
setTimeout(() => {
this.set({ isPlaying: true });
}, 0);
current.replayer.play(0);
if (!current.autoPlay) {
let firstFullSnapshotRebuilded = false;
current.replayer.on('fullsnapshot-rebuilded', () => {
if (!firstFullSnapshotRebuilded) {
firstFullSnapshotRebuilded = true;
current.replayer.pause();
}
});
}
current.replayer.on('pause', () => {
this.set({ isPlaying: false });
});