fix media playback bug (#80)
This commit is contained in:
@@ -202,10 +202,14 @@ function buildNode(
|
|||||||
if (name === 'rr_height') {
|
if (name === 'rr_height') {
|
||||||
(node as HTMLElement).style.height = value;
|
(node as HTMLElement).style.height = value;
|
||||||
}
|
}
|
||||||
|
if (name === 'rr_mediaCurrentTime') {
|
||||||
|
(node as HTMLMediaElement).currentTime = n.attributes.rr_mediaCurrentTime as number
|
||||||
|
}
|
||||||
if (name === 'rr_mediaState') {
|
if (name === 'rr_mediaState') {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 'played':
|
case 'played':
|
||||||
(node as HTMLMediaElement).play();
|
(node as HTMLMediaElement).play().catch(e => console.warn("media playback error", e));
|
||||||
|
break;
|
||||||
case 'paused':
|
case 'paused':
|
||||||
(node as HTMLMediaElement).pause();
|
(node as HTMLMediaElement).pause();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -464,6 +464,7 @@ function serializeNode(
|
|||||||
attributes.rr_mediaState = (n as HTMLMediaElement).paused
|
attributes.rr_mediaState = (n as HTMLMediaElement).paused
|
||||||
? 'paused'
|
? 'paused'
|
||||||
: 'played';
|
: 'played';
|
||||||
|
attributes.rr_mediaCurrentTime = (n as HTMLMediaElement).currentTime
|
||||||
}
|
}
|
||||||
// scroll
|
// scroll
|
||||||
if ((n as HTMLElement).scrollLeft) {
|
if ((n as HTMLElement).scrollLeft) {
|
||||||
|
|||||||
Reference in New Issue
Block a user