-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disconnecting media element from MediaElementAudioSourceNode #1202
Comments
Using In light of this, I'm closing this issue. |
But what if we want the user to be able to control the volume of the media? Are we forced to proxy the existing volume controlling code to a |
As far as I can tell, the workaround @padenot mentioned doesn't work in Chromium due to an incorrect implementation: https://bugs.chromium.org/p/chromium/issues/detail?id=1136404 https://w3c.github.io/mediacapture-fromelement/#dom-htmlmediaelement-capturestream says:
Try |
I came up with a different workaround where you don't have problems with Instead of context = new AudioContext();
elementSource = context.createMediaElementSource(el);
togglingGain = context.createGain();
togglingGain.gain.value = 0;
elementSource
.connect(togglingGain)
.connect(context.destination)
;
// Do this is you want to detach
myDetachMediaElement = () => {
togglingGain.gain.value = 1;
}
streamSource = context.createMediaStreamSource(el.captureStream());
elementVolumeReplicatingGain = context.createGain();
streamSource.connect(elementVolumeReplicatingGain);
elementVolumeReplicatingGain.gain.value = el.volume;
el.addEventListener('volumechange', () => {
elementVolumeReplicatingGain.gain.value = el.volume;
});
// Then use `elementVolumeReplicatingGain` instead of `elementSource` for your applications.
elementVolumeReplicatingGain.connect(context.destination); // For example But |
Only issue is |
Currently, once you create a
MediaElementAudioSourceNode
all audio from the media element is sent to this node. But what if I'm done with this routing? Currently there's no way to break this connection. Waiting for GC to collect the media node and undoing the routing is a terrible way because you're not in control of when that happens.There should be a way to break this connection, perhaps by adding a new
detach
(name TBD) method or allowing the user to set themediaElement
attribute tonull
. (I prefer a new method.)The same issue applies to a
MediaStreamAudioSourceNode
.The text was updated successfully, but these errors were encountered: