Is there a way to capture the output of a browser using the Web Audio API and manipulate it?

In a webpage, I would like to embed an audio track from spotify/youtube/other streaming service, and capture the audio in a way that I could then manipulate it with the Web Audio API (or Tone.js, or any other method). For example apply a StereoPannerNode to it, and then output the audio to my default output.
Another option is to capture any audio from my device and manipulate it.

I tried to find a solution to this problem, but couldn’t find a way to “capture” the audio from my browser’s output / from an iframe.

Anyone have an idea how to achieve this?