After Soundcloud updated his API, I'm hitting a bug, I think. When you play a sound, you can pause it and after you paused, you can play the track again. But when you hit the button again, it doesn't pause the track. Only when you click 2 times more it will stop playing.
I can't find a solution for this, so does anyone know what I do wrong or is this a real bug inside the Soundcloud API?
The site is: www.mrooneh.com I use the following code to handle the play/pause button.
var isPlaying = false;
$('.control').click(function(event) {
event.preventDefault();
var trackID = $(this).closest('li').attr('data-id');
// console.log(trackID);
if ( $(this).hasClass('play pause') ) {
// console.log('stop track');
isPlaying = false;
console.log('isPause')
$('#playlist li a').removeClass('pause');
$(this).addClass('play');
}
else {
// console.log('pause/stop track');
isPlaying = true;
console.log('isPlaying')
$('#playlist li a').removeClass('pause');
$(this).addClass('pause');
}
if (!isPlaying) {
nowPlaying.pause();
}
// SC.stream('/tracks/' + trackID, function(sound) {
SC.stream('/tracks/' + trackID).then(function(player) {
nowPlaying = player;
if (isPlaying) {
// console.log('play');
player.play();
} else {
// console.log('pause');
player.pause();
}
});
});
And is there a way to stop the track, after you go to another one instead of pause the track?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire