@@ -240,7 +240,7 @@ export class WebAudioTransport {
240240 private _pendingDecodeBytes = new Map < string , number > ( ) ;
241241 private _failedSrcs = new Set < string > ( ) ;
242242 private _mediaElementSources = new WeakMap < HTMLMediaElement , MediaElementAudioSourceNode > ( ) ;
243- private _handedOver = new WeakSet < HTMLMediaElement > ( ) ;
243+ private _handedOver = new Set < HTMLMediaElement > ( ) ;
244244 private _activeSources : ScheduledSource [ ] = [ ] ;
245245 private _masterGain : GainNode | null = null ;
246246 /** Where the master bus chain lands; the program meter taps here. */
@@ -1052,8 +1052,7 @@ export class WebAudioTransport {
10521052 }
10531053 }
10541054
1055- /** Drops the routed element's source once a decoded buffer plays in its place. A captured element has no native
1056- * output, so left unconnected it is silent; WebKit sounds it through the destination even while muted. */
1055+ /** Drops the routed element's source once a decoded buffer plays in its place; it stays silent until a stop. */
10571056 releaseRouted ( el : HTMLMediaElement ) : void {
10581057 const routed = this . _activeSources . find ( ( s ) => s . el === el && s . sourceKind === "media-element" ) ;
10591058 if ( ! routed ) return ;
@@ -1133,11 +1132,23 @@ export class WebAudioTransport {
11331132 stopAll ( ) : void {
11341133 for ( const source of this . _activeSources ) this . dispose ( source ) ;
11351134 this . _activeSources = [ ] ;
1135+ this . reconnectHandedOver ( ) ;
11361136 this . _paused = true ;
11371137 this . _playGeneration += 1 ;
11381138 this . rest ( ) ;
11391139 }
11401140
1141+ private reconnectHandedOver ( ) : void {
1142+ for ( const el of this . _handedOver ) {
1143+ try {
1144+ if ( this . _ctx ) this . _mediaElementSources . get ( el ) ?. connect ( this . _ctx . destination ) ;
1145+ } catch ( err ) {
1146+ swallow ( "webAudioTransport.reconnectHandedOver" , err ) ;
1147+ }
1148+ }
1149+ this . _handedOver . clear ( ) ;
1150+ }
1151+
11411152 /** Stops what plays from media gone from the page, without sending it to the destination as a stop does. */
11421153 releaseDetached ( ) : void {
11431154 this . _activeSources = this . _activeSources . filter ( ( source ) => {
0 commit comments