P粉5369091862023-08-31 10:10:19
要关闭所有东西,下面的方法似乎有效。我只是通过试错找到了这个方法,因为我无法弄清楚如何让Safari告诉我它仍然持有什么:
// stream : MediaStream // sourceNode : MediaStreamAudioSourceNode // recorderNode : AudioWorkletNode const tracks = stream.getTracks(); tracks.forEach((track) => { track.stop(); stream.removeTrack(track) }); stream = null sourceNode.disconnect(); sourceNode = undefined recorderNode.disconnect(); recorderNode = undefined