Frage

I currently allow users to log in through Soundcloud and I created a list of track ID's of their music.

With this data, I created an array of all the track ID and randomized it. How can I go about playing these songs? This works for individual tracks:

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

But how can I get a notice for when the song ends so I can begin a new track?

update:

I could record the duration of the song and setTimeout the stopping and playing of a new track but maybe there is a more Soundcloud way to do this.

Thanks

War es hilfreich?

Lösung

Use the onfinish method

SC.stream("/tracks/###", 
{onfinish: function(){ alert('track finished');}}, 
function(sound){sound.play();
});

Here is another thread around the same issue.

How can I automatically move to next sound after previous track completes using the Soundcloud Javascript SDK for streaming?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top