fix media playback bug (#80)

This commit is contained in:
bachmanity1
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 17b79ca210
commit 5fbb459a8e
2 changed files with 6 additions and 1 deletions

View File

@@ -202,10 +202,14 @@ function buildNode(
if (name === 'rr_height') {
(node as HTMLElement).style.height = value;
}
if (name === 'rr_mediaCurrentTime') {
(node as HTMLMediaElement).currentTime = n.attributes.rr_mediaCurrentTime as number
}
if (name === 'rr_mediaState') {
switch (value) {
case 'played':
(node as HTMLMediaElement).play();
(node as HTMLMediaElement).play().catch(e => console.warn("media playback error", e));
break;
case 'paused':
(node as HTMLMediaElement).pause();
break;

View File

@@ -464,6 +464,7 @@ function serializeNode(
attributes.rr_mediaState = (n as HTMLMediaElement).paused
? 'paused'
: 'played';
attributes.rr_mediaCurrentTime = (n as HTMLMediaElement).currentTime
}
// scroll
if ((n as HTMLElement).scrollLeft) {