Closed sheadawson closed 10 years ago
The ToneDenReady callback functions are called only once, immediately after the SDK has been loaded asynchronously. If you push a function to the ToneDenReady array once the SDK has already loaded, it will not be called.
I would check to see if the SDK is loaded already by checking for the existence of ToneDen.player. if it exists, you can call the ToneDen.player.create function directly. If not, you should add the call to the ToneDenReady array.
Let me know if this works!
Cheers for the quick response. Yes this makes sense worked perfectly. Here's the code I used if anyone else is trying to do this.
function initToneden(){
var config = {
dom: "#toneden-soundcloud",
skin: "dark",
visualizer:"waves",
tracksPerArtist: 999,
urls: [
"https://soundcloud.com/opiuo"
]
};
if(typeof ToneDen != 'undefined'){
ToneDen.player.create(config);
}else{
ToneDenReady.push(function() {
ToneDen.player.create(config);
});
}
};
Thanks again :D
@sheadawson great! If you don't mind forwarding us a link to your page/project we would be happy to feature it in a 'Examples' section that we will be adding to our README :)
Sure thing, will be deploying later today and will send you a link
On Tue, Apr 22, 2014 at 9:14 AM, Tim Thimmaiah notifications@github.comwrote:
@sheadawson https://github.com/sheadawson great! If you don't mind forwarding us a link to your page/project we would be happy to feature it in a 'Examples' section that we will be adding to our README :)
Reply to this email directly or view it on GitHubhttps://github.com/ToneDen/toneden-sdk/issues/13#issuecomment-40987738 .
Shea Dawson Web Developer LiveSource
mobile +61 451125303 skype squatchnz email shea@livesource.co.nz web www.livesource.co.nz
The player is now live on the home page of http://opiuo.com. Cheers!
@sheadawson looks awesome :+1:
Hello,
I'm trying to initialise the toneden player after the html containing the #player element is loaded via ajax. My code follows the example and works fine if #player is present on the initial page load.
All I've done is added the following code to my ajax callback.
I don't get any console errors, the anonymous functioned pushed in ToneDenReady.push(function() { does not run.
I would have thought this would work fine... should it? Or am I doing something wrong?
Thanks in advance and cheers for a neat player.