-
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
A way to a) detect if MediaElementAudioSourceNode
is CORS-restricted & b) revert createMediaElementSource
#2453
Comments
Turns out the "b)" part is a duplicate of #1202, sorry. I'll write some comments there. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
To analyze the volume of the media. Here's the extension itself: https://github.com/WofWca/jumpcutter.
The method you described is very hard (if possible) to implement so that it works on (almost) every website, and it's a bit invasive (it requires changing the
This to me also sounds like a headache to get working everywhere. It requires either creating a new element with the same source, or manipulating the original one. Anyway, I appreciate your response. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
How about using Object URL ? fetch('https://mirrors.creativecommons.org/movingimages/webm/ScienceCommonsJesseDylan_240p.webm#t=10,20')
.then((response) => response.blob())
.then((blob) => {
const objectURL = window.URL.createObjectURL(blob);
const mediaElement = document.querySelector('audio');
mediaElement.src = objectURL;
const context = new AudioContext();
const source = new MediaElementAudioSourceNode(context, { mediaElement });
source.connect(context.destination);
mediaElement.play();
})
.catch(console.error); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Audio WG call:
This way this works consistently with |
@guest271314 I'll take time to think about the workarounds you suggested, but currently I'm inclined to think that having such API would be nice either way. |
Also regarding b): |
The idea on #2453 (comment) still stands. The CORS property should be queried via MediaElement. |
This Stack Overflow answer states that But it looks like that behavior is only specified for a
It is not specified for
|
Describe the feature
Perhaps for a) a boolean property and an event emission (in case e.g.
element.currentSrc
changed from same-origin to cross-origin or vice versa) would do.b) is needed in order to not "break" the element whose
src
is CORS-restricted so at least it is possible for the user to hear its sound.It also can come in handy if you decided to switch to a different
AudioContext
(e.g. you don't likesampleRate
orlatencyHint
of the current one).Or perhaps
createMediaElementSource
needs to be replaced with something that doesn't cause this trouble.Is there a prototype?
No.
Describe the feature in more detail
For context, I'm developing an extension which calls
AudioContext.createMediaElementSource
for every media element on every page.As we know, cross-origin media playback is allowed, but
MediaElementAudioSourceNode
outputs zeroes for such media (https://webaudio.github.io/web-audio-api/#MediaElementAudioSourceOptions-security), which means that when you callcreateMediaElementSource
for such media it simply gets muted with no conservative (meaning without re-creating the element or something like this) way to revert it, which (at least in my case) is worse than not calling the method at all.Some websites fetch media data from a different origin (and even a different subdomain is a different origin - see, for example, Zoom recordings), but the
Access-Control-Allow-Origin
header is not always applied to such media responses, which makescreateMediaElementSource
(therefore my extension) not only useless but even harmful.In a perfect world it would also be nice if
createMediaElementSource
always just worked for browser extensions somehow. Web Audio API may not be the only scope this issue lies in in this case (then I would appreciate if someone gave me directions on how to proceed).And FYI I'm not the greatest web guru, I may just be missing something.
The text was updated successfully, but these errors were encountered: