I am using the following code to embed a soundcloud widget:
SC.oEmbed(soundcloud_url, {color: "3C9FCE"}, document.getElementById('container_id'));
How do I bind a SC.Widget.Events.Ready to it? I don't see any way to set the id or class of the embed iframe so that I can select it. Nor do I know when it has been loaded so that I can bind it, such as the following dysfunctional code:
var frame = document.getElementById('container_id').getElementsByTag("iframe")[0];
frame.bind(SC.Widget.Events.Ready, listnerFucnt());
Thanks!
If the reason you are using SoundCloud JavaScript SDK is to be able to
SC.oembed
to get embed HTML when having only SoundCloud permalink, then you probably shouldn't. You can interact with either/resolve
or/oembed
endpoints instead.The difference is that
/oembed
endpoint doesn't requireclient_id
to be specified in request, so let's start with this approach first.Option 1
I'll use jQuery, but the idea should be clear:
This code live and commented – http://jsbin.com/ilesum/2/edit
Option 2
The other thing you could do is to use
/resolve
endpoint, but you have to specifyclient_id
in order to interact with it, plus you will need to construct Widget iframe HTML yourself (which isn't too bad though):And example live as well http://jsbin.com/oqebuk/2/edit
Please note you can disable HTML or Output panes on JSBin, so it's easier to read the example JavaScript code.