@@ -304,6 +304,10 @@ function ffmpegFailure(
304304export function parseAudioElements ( html : string ) : AudioElement [ ] {
305305 const elements : AudioElement [ ] = [ ] ;
306306 const { document } = parseHTML ( unwrapTemplate ( html ) ) ;
307+ interface AudioMediaElement extends RefResolverEl {
308+ hasAttribute ( name : string ) : boolean ;
309+ parentElement : AudioMediaElement | null ;
310+ }
307311
308312 // Shared resolver state so a relative `data-start` ("start when clip X ends")
309313 // resolves against every clip in the composition — exactly as
@@ -321,6 +325,12 @@ export function parseAudioElements(html: string): AudioElement[] {
321325 const end = raw ? parseFloat ( raw ) : 0 ;
322326 return Number . isFinite ( end ) ? end : 0 ;
323327 } ;
328+ const isHidden = ( el : AudioMediaElement ) : boolean => {
329+ for ( let current : AudioMediaElement | null = el ; current ; current = current . parentElement ) {
330+ if ( current . hasAttribute ( "data-hidden" ) ) return true ;
331+ }
332+ return false ;
333+ } ;
324334
325335 // <audio> and <video data-has-audio> tracks differ only in the emitted id
326336 // and `type`; everything else (timing, layer, volume) is read identically.
@@ -342,13 +352,13 @@ export function parseAudioElements(html: string): AudioElement[] {
342352
343353 for ( const el of document . querySelectorAll ( "audio[id][src]" ) ) {
344354 const id = el . getAttribute ( "id" ) ;
345- if ( ! id || ! el . getAttribute ( "src" ) ) continue ;
355+ if ( ! id || ! el . getAttribute ( "src" ) || isHidden ( el ) ) continue ;
346356 elements . push ( build ( el , id , "audio" ) ) ;
347357 }
348358
349359 for ( const el of document . querySelectorAll ( 'video[id][src][data-has-audio="true"]' ) ) {
350360 const id = el . getAttribute ( "id" ) ;
351- if ( ! id || ! el . getAttribute ( "src" ) ) continue ;
361+ if ( ! id || ! el . getAttribute ( "src" ) || isHidden ( el ) ) continue ;
352362 elements . push ( build ( el , `${ id } -audio` , "video" ) ) ;
353363 }
354364
0 commit comments