I am trying to create a simple multi-track player based on Soundcloud that displays several tracks and starts playing them simultaneously.
I found a similar prototype here (based on Flash widgets): http://sessian.com/10/
By pressing two different Play buttons, two tracks can be played together.
It seems that using HTML5 widgets instead is not possible, only one track can be played at a time. A quick example is here: http://jsfiddle.net/ftwJr/7/
Html:
<iframe id="widget" src='http://w.soundcloud.com/player/?url=http://api.soundcloud.com/tracks/43315398&auto_play=true' width="100%"></iframe> <iframe id="widget2" width="100%" src='http://w.soundcloud.com/player/?url=http://api.soundcloud.com/tracks/4331538'></iframe>
JavaScript:
(function() { var iframe = document.querySelector('#widget'); var widget = SC.Widget(iframe); widget.bind(SC.Widget.Events.PLAY, function(eventData) { alert('Playing 1...'); }); widget.bind(SC.Widget.Events.PAUSE, function(eventData) { alert('PAUSE 1...'); }); var iframe2 = document.querySelector('#widget2'); var widget2 = SC.Widget(iframe2); widget2.bind(SC.Widget.Events.PLAY, function(eventData) { alert('Playing 2...'); }); widget2.bind(SC.Widget.Events.PAUSE, function(eventData) { alert('PAUSE 2...'); }); }());
Pressing the "Play" button will transfer the pause event to another window. This is also true in different browser tabs.
Is there a way to allow multiple simultaneous games using HTML5 widgets? (An existing SC initialization option or a way to have two different SC instances or ...)
Thanks!
Fradigomma
source share