I'm developing app to play soundcloud traks. I'm using ttwmusicplayer and want to bind soundcloud actions on it's play/pause. So, I'm doing it like this:
$("#mainPlayer .jp-play")
.off("click")
.on("click", function(){
$("#mainPlayer .jp-play").css('display','none');
$("#mainPlayer .jp-pause").css('display','block');
SC.stream('/tracks/208818225', function(sound){
sound.play();
});
});
$("#mainPlayer .jp-pause")
.off("click")
.on("click", function(){
alert('IT WORKS');
$("#mainPlayer .jp-play").css('display','block');
$("#mainPlayer .jp-pause").css('display','none');
SC.stream('/tracks/208818225', function(sound){
sound.stop();
});
});
It plays track fine,but when I click pause button, I receive alert, so I can understand that this works. Also pause changes itself on play, but music still playing, however I found this methond in docs How can I pause/stop soundcloud tracks then?
I think there should be one sound object
and to stop sound no need to use SC.stream instead just use the sound object. like: