html5 - SoundCloud embedded track: How to refresh page after the track ends playing? -
first off, quite noob.
ok, have embedded soundcloud track webpage. question is, how refresh page (or else) when track ends?
can getduration(i found on soundcloud api page)?
i tried code it. in code tried duration of track , print on screen/webpage. wrong code?
<script src="https://w.soundcloud.com/player/api.js" type="text/javascript"></script> <span id="headerleft-content"> <script type="text/javascript"> var duration = 0; (function(){ var widgetiframe = document.getelementbyid('sc-widget'), widget = sc.widget(widgetiframe); widget.bind(sc.widget.events.ready, function() { widget.getduration(function(val) { duration = val; }); }); }()); document.write(duration); </script> </span>
if worked, put wait(duration) , refresh...
in other words, can soundcloud embedded track "hacked" loop(or refresh page after track over, that's want do) though original widget doesn't support looping?
please, take @ soundcloud html5 widget page found getduration command , see if can me... => http://developers.soundcloud.com/docs/api/html5-widget#getters
edit:
<script> var html=<iframe blablabla...></iframe> document.write(html); </script> <script src="https://w.soundcloud.com/player/api.js" type="text/javascript"></script> <script type="text/javascript"> (function(){ var widgetiframe = document.getelementbyid('sc-widget'), widget = sc.widget(widgetiframe), widget.bind(sc.widget.finish, function() { window.location.reload(false); }); }()); </script>
page doesn't refresh after track over. can see what's wrong?
you can bind function sc.widget.finish
event documented here. following code snippet should work:
widget.bind(sc.widget.finish, function() { window.location.reload(false); });
of course if want widget loop, use seekto
, play
methods:
widget.bind(sc.widget.finish, function() { // again, again! widget.seekto(0); widget.play(); });
that less intrusive page refresh.