44 injectDurations ,
55 extractResolvedMedia ,
66 clampDurations ,
7- shouldClampMediaDuration ,
7+ shouldClampResolvedMediaDuration ,
88 type ResolvedDuration ,
99} from "./timingCompiler" ;
1010
@@ -23,7 +23,8 @@ function resolveMediaSrc(src: string, projectDir: string): string {
2323 *
2424 * 1. Static pass: compileTimingAttrs() adds data-end where data-duration exists
2525 * 2. For unresolved video/audio (no data-duration): probe via probeMediaDuration, inject durations
26- * 3. For pre-resolved video/audio: validate data-duration against actual source, clamp if needed
26+ * 3. For pre-resolved audio: clamp data-duration to playable source when needed.
27+ * Explicit video slots are preserved and hold their final frame.
2728 *
2829 * @param rawHtml - The raw HTML string
2930 * @param projectDir - The project directory for resolving relative paths
@@ -54,18 +55,17 @@ export async function compileHtml(
5455 if ( fileDuration <= 0 ) continue ;
5556
5657 const effectiveDuration = fileDuration - el . mediaStart ;
57- resolutions . push ( {
58- id : el . id ,
59- duration : effectiveDuration > 0 ? effectiveDuration : fileDuration ,
60- } ) ;
58+ const sourceDuration = effectiveDuration > 0 ? effectiveDuration : fileDuration ;
59+ resolutions . push ( { id : el . id , duration : sourceDuration } ) ;
6160 }
6261
6362 if ( resolutions . length > 0 ) {
6463 html = injectDurations ( html , resolutions ) ;
6564 }
6665 }
6766
68- // Phase 2: Validate pre-resolved media — clamp data-duration to actual source duration
67+ // Phase 2: Bound authored audio to playable source. Explicit video slots may
68+ // outlive their source and render by holding the final frame.
6969 const preResolved = extractResolvedMedia ( html ) ;
7070 const clampList : ResolvedDuration [ ] = [ ] ;
7171
@@ -77,7 +77,7 @@ export async function compileHtml(
7777 if ( fileDuration <= 0 ) continue ;
7878
7979 const maxDuration = fileDuration - el . mediaStart ;
80- if ( maxDuration > 0 && shouldClampMediaDuration ( el . duration , maxDuration ) ) {
80+ if ( maxDuration > 0 && shouldClampResolvedMediaDuration ( el . tagName , el . duration , maxDuration ) ) {
8181 clampList . push ( { id : el . id , duration : maxDuration } ) ;
8282 }
8383 }
0 commit comments