4
votes

I'm using the Soundcloud API for streaming and it's working beautifully on desktop but not on mobile (only testing iphone and ipad at this point).

The problem appears to be when I attempt to use the streaming SDK. Using the snippet below which comes straight from the Soundcloud docs is not even working on mobile. https://developers.soundcloud.com/docs/api/sdks#streaming

SC.stream("/tracks/293", function(sound){
  sound.play();
});

If I console.log the sound variable, I get false, instead of the Soundcloud stream object I would expect.

SC.stream("/tracks/293", function(sound){
  console.log(sound); // false
});

Getting a track using SC.get isn't a problem as I'm getting an object returned so Soundcloud is properly initialized.

Any help on this would be hugely appreciated.

Thanks!

1
I am having the exact same issue. Please post back here if you find a solution... I'll do the same. Good luck! - Dylan Reich
Yeah it's a strange one, no mention of it not working on their docs that i can see. A workaround is to just not use SC.stream and instead create your own audio element, and simply give it a src that points to the track endpoint with your client ID as a parameter e.g. api.soundcloud.com/tracks/[trackId]/stream?client_id=[ SOUNDCLOUD_ID]. Then you can play the stream using the normal methods, properties, and events. w3schools.com/tags/ref_av_dom.asp - simonnn
I am having the same issue. It seems if you hook up the stream to a click event it works (e.g. el.onclick = function() {SC.stream('/tracks/123', {autoPlay: true});};) but I can't get it to play on page load. I've tweeted a link to this question to the SoundCloud devs in hope of a response. - goodforenergy
apple doesn't allow, as of today, any autoplay features. but at least it works with a click! - Francesco

1 Answers

0
votes
SC.initialize({
  client_id:'YOUR CLIENT ID'
});

SC.stream("/tracks/293").then(function(sound){
  sound.play();   
});