mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-10 22:20:14 +00:00
fix(core): apply playbackRate to all media duration resolution sites (#1288)
Extract readElementPlaybackRate() to eliminate clamping duplication across media.ts, init.ts, startResolver.ts, and timeline.ts. Apply the rate division to the two remaining sites that were missed: - startResolver.ts: visibility loop used raw source duration, hiding slowed-down videos mid-playback when no data-duration was set - timeline.ts: resolveMediaElementDurationSeconds underreported the end window sent to the renderer, affecting preview parity Also adds direct tests for readElementPlaybackRate().
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { RuntimeTimelineLike } from "./types";
|
||||
import { swallow } from "./diagnostics";
|
||||
import { readElementPlaybackRate } from "./media";
|
||||
|
||||
const AUTHORED_DURATION_ATTR = "data-hf-authored-duration";
|
||||
const AUTHORED_END_ATTR = "data-hf-authored-end";
|
||||
@@ -106,7 +107,7 @@ export function createRuntimeStartTimeResolver(params: {
|
||||
parseNumeric(element.getAttribute("data-media-start")) ??
|
||||
0;
|
||||
if (Number.isFinite(element.duration) && element.duration > playbackStart) {
|
||||
resolved = element.duration - playbackStart;
|
||||
resolved = (element.duration - playbackStart) / readElementPlaybackRate(element);
|
||||
}
|
||||
}
|
||||
if (resolved == null || resolved <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user