I am embedding various players on my webpage (YouTube, Spotify, Bandcamp etc.) and would like to change my webpage's state based on the embedded sound. How can this data be accessed?
UPDATE: From evolutionxbox 's comment, I looked into the element of one of the Bandcamp embedded players, and found the below:
<script type="text/javascript">
var playerdata = {"tracks":[{"title":"Virga I","encodings_id":1606233426,"file":{"mp3-128":"https://t4.bcbits.com/stream/.....
var parentpage = "http://localhost:8080/"; // page we are embedded in
var params = {"tracklist":"false","fgcol":null,"url_referrer":false...
$(function() {
HTMLEmbeddedPlayer3.init(playerdata, parentpage, params);
});
</script>
This is cool, because I may be able to see this iframe's "playerdata" var programmatically, and access the audio when the user clicks play? I'll be giving it a try.
EXTRA:
I also found this helpful thread: Is there anyway to visualize youtube audio from an iframe using the web audio api?
However this solves for only YouTube. Other services (and I'm mainly looking at Bandcamp here) don't have an API to stream the audio, so it would have to be from the iframe itself.
Since the audio is playing on the site it seems there ought to be some way to intercept between the media service and the user, but right now I'm not seeing it.