2

I'm using the SoundCloud HTML5 iFrame widget and I'm trying to trigger an event when it finishes. The first time a song finishes, the event triggers. But when I play another song the same way after the finish event has triggered, the FINISH event won't trigger a second time!

It's basically the same problem as: Soundcloud HTML5 Player: Events.FINISH only fired once

Although in my case, I'm already using the new api.js without the parentWindow call.

I'm using the API.js at: http://w.soundcloud.com/player/api.js

I've got an iframe on my page like this:

When playing a song, the event is attached as followed:

var widgetIframe = document.getElementById('soundcloud-container'),
widget       = SC.Widget(widgetIframe);

widget.bind(SC.Widget.Events.FINISH, function(player, data) {
  console.log('finished');
  playNextTrack();                  
});

In the playNextTrack() method, the same code is executed to attach the event again. But now, it isn't triggering anymore. All other code in the playNextTrack is executed as expected, but the SC.Widget.Events.FINISH isn't. It doesn't show an error message in the console either.

Does anyone know what I might be doing wrong?

1
  • 1
    Hey Rick, it would be really cool if you'd put the code you are using on jsbin.com or jsfiddle.net (including playNextTrack function), so we are sure 100% what is not working for you. Dec 7, 2012 at 14:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.