Live data from Hacker News

Web Audio API Is a W3C Recommendation

w3.org

11–20 of 33 posts

Re: Web Audio API Is a W3C Recommendation

#11
I really wish you could access audio data from across an origin. Preventing that access seems to me like it's mostly just nice for YouTube, Spotify, SoundCloud et al to not have others do things with their audio/video data. Why should my browser care to help them like that?

For example, I have built a few music visualizers and have had to run a local youtube-dl server that disables cors, just to be able to visualize music for a youtube video. I just want to draw patterns on my screen while some music plays, I'd even be fine with the ads! But I have to engage in some form of piracy to do this.

The music is already playing through my speakers, so I should be able to access that data!

(edit: I want to clarify: I know that one can set cors options on audio elements to enable cross-origins references, but it requires the server to allow you to -- which is what I'm doing with the youtube-dl server. That is the real problem: CORS is being used by youtube for copyright protection, not for user-safety. I know that accessing a youtube video across origins from a page I wrote myself is safe, but CORS enables youtube to stop me from accessing that data, in the name of safety.)

Re: Web Audio API Is a W3C Recommendation

#12
post #11

I really wish you could access audio data from across an origin. Preventing that access seems to me like it's mostly just nice for YouTube, Spotify, SoundCloud et al to not have others do things with their audio/video data. Why should my browser care to help them like that? For example, I have built a few music visualizers and have had to run a local youtube-dl server that disables cors, just to be able to visualize…

I’d rather not allow other tabs to listen in on my meetings in google meet, zoom or teams. How would this work securely? Seems like it would need to be opt-in for each site as well as requiring user consent.

Re: Web Audio API Is a W3C Recommendation

#13
post #5

Earlier quoted context omitted.

Most of the Web Audio stuff has already been present in all major browsers for a little while, this mostly standardises what's already there. The main thing that this brings in that up until now was just a feature of Chrome is the AudioWorklet, so real-time low-level audio processing in JS worklets will work cross-browser when its implemented in the other browsers. It's very difficult to implement low-level audio pro…

AudioWorklet (which allows you to work with audio sample-by-sample in a dedicated, high priority "thread") is available and works well in Firefox and the latest Safari. I haven't tried it in Edge, but I believe it's also working well.

Safari on iOS is still missing some important features that severely limits its usage.

Re: Web Audio API Is a W3C Recommendation

#15
post #11

I really wish you could access audio data from across an origin. Preventing that access seems to me like it's mostly just nice for YouTube, Spotify, SoundCloud et al to not have others do things with their audio/video data. Why should my browser care to help them like that? For example, I have built a few music visualizers and have had to run a local youtube-dl server that disables cors, just to be able to visualize…

You can from an extension, iirc – so it shouldn't be too hard to use an extension to smuggle the stream between the contexts without needing to copy the data.

Re: Web Audio API Is a W3C Recommendation

#16

And I'm sure iOS Safari will still keep annoying restrictions on using it. I 100% understand the reasoning behind not allowing sound to play unless it's "user initiated" but it's really frustrating how small that window is and/or how you can't ask for that "permission". I have a web app that uses the camera for scanning (don't get me started on how Chrome/FF/etc on iOS can't use the camera for streaming) and in Safar…

Once you play a sound, you’re allowed to keep playing sounds I think. Just play a silent track until sound is needed

Re: Web Audio API Is a W3C Recommendation

#17

And I'm sure iOS Safari will still keep annoying restrictions on using it. I 100% understand the reasoning behind not allowing sound to play unless it's "user initiated" but it's really frustrating how small that window is and/or how you can't ask for that "permission". I have a web app that uses the camera for scanning (don't get me started on how Chrome/FF/etc on iOS can't use the camera for streaming) and in Safar…

Once you play a sound, you’re allowed to keep playing sounds I think. Just play a silent track until sound is needed

I might have to try this again but I think I tried this at some point and I failed to get it working but it might have been making a mistake.

Re: Web Audio API Is a W3C Recommendation

#18

And I'm sure iOS Safari will still keep annoying restrictions on using it. I 100% understand the reasoning behind not allowing sound to play unless it's "user initiated" but it's really frustrating how small that window is and/or how you can't ask for that "permission". I have a web app that uses the camera for scanning (don't get me started on how Chrome/FF/etc on iOS can't use the camera for streaming) and in Safar…

Once you play a sound, you’re allowed to keep playing sounds I think. Just play a silent track until sound is needed

Which, to the parent's point, makes the restriction itself pointless? It also seems like the kind of "workaround" that will one day be patched, and suddenly your app stops working.

Re: Web Audio API Is a W3C Recommendation

#19

And I'm sure iOS Safari will still keep annoying restrictions on using it. I 100% understand the reasoning behind not allowing sound to play unless it's "user initiated" but it's really frustrating how small that window is and/or how you can't ask for that "permission". I have a web app that uses the camera for scanning (don't get me started on how Chrome/FF/etc on iOS can't use the camera for streaming) and in Safar…

I just hacked together a workaround for this very thing myself. You can call play() in a click handler but immediately pause(), and then call play() again on the same Audio element later when your scanner succeeds.

Re: Web Audio API Is a W3C Recommendation

#20
post #12
post #11

I really wish you could access audio data from across an origin. Preventing that access seems to me like it's mostly just nice for YouTube, Spotify, SoundCloud et al to not have others do things with their audio/video data. Why should my browser care to help them like that? For example, I have built a few music visualizers and have had to run a local youtube-dl server that disables cors, just to be able to visualize…

I’d rather not allow other tabs to listen in on my meetings in google meet, zoom or teams. How would this work securely? Seems like it would need to be opt-in for each site as well as requiring user consent.

That's reasonable. :)

Those things should already require authorization to access their streams, and your creds for e.g. meet.google.com shouldn't be available in other tabs/windows at other domains to send along, but it still would likely be reasonable to default to preventing access to/from domains unless they are marked as safe, in much the same way accesses are already requested/allowed.

I acknowledge that a feature like that would take real work to write and support and keep secure, but control over access to data should be the user's choice, not the server's.

Post reply on HN