@@ -2420,16 +2420,19 @@ export function initSandboxRuntimeModular(): void {
24202420 }
24212421 } ;
24222422
2423+ const authoredMediaVolume = ( el : HTMLMediaElement ) : number | null => {
2424+ const parsed = Number . parseFloat ( el . dataset . volume ?? "" ) ;
2425+ return Number . isFinite ( parsed ) ? Math . max ( 0 , Math . min ( 1 , parsed ) ) : null ;
2426+ } ;
2427+
24232428 const bindMediaMetadataListeners = ( ) => {
24242429 if ( state . tornDown ) return ;
24252430 const mediaEls = Array . from ( document . querySelectorAll ( "video, audio" ) ) as HTMLMediaElement [ ] ;
24262431 for ( const mediaEl of mediaEls ) {
24272432 if ( metadataBoundMedia . has ( mediaEl ) ) continue ;
24282433 metadataBoundMedia . add ( mediaEl ) ;
2429- const parsedVolume = Number . parseFloat ( mediaEl . dataset . volume ?? "" ) ;
2430- if ( Number . isFinite ( parsedVolume ) ) {
2431- mediaEl . volume = Math . max ( 0 , Math . min ( 1 , parsedVolume ) ) ;
2432- }
2434+ const volume = authoredMediaVolume ( mediaEl ) ;
2435+ if ( volume !== null ) mediaEl . volume = volume ;
24332436 mediaEl . addEventListener ( "loadedmetadata" , scheduleMetadataDurationHydration ) ;
24342437 mediaEl . addEventListener ( "durationchange" , scheduleMetadataDurationHydration ) ;
24352438 // Web Audio eligibility, reported at DISCOVERY rather than only at
@@ -3333,8 +3336,9 @@ export function initSandboxRuntimeModular(): void {
33333336 else kept . setAttribute ( "style" , style ) ;
33343337 // The swap's closing pass puts its move back, as a load's first pass does.
33353338 forgetPositionEdit ( kept as HTMLElement ) ;
3336- // Properties no attribute shows, as the runtime sets them; the volume probe below redoes volume .
3339+ // Properties no attribute shows, as a load sets them.
33373340 const media = kept as HTMLMediaElement ;
3341+ media . volume = authoredMediaVolume ( media ) ?? 1 ;
33383342 media . muted = state . bridgeMuted || state . mediaOutputMuted || media . defaultMuted ;
33393343 media . defaultPlaybackRate = 1 ;
33403344 media . playbackRate = state . playbackRate ;
0 commit comments