javascript - SoundCloud Cross-Origin Request Blocked at https://l9bjkkhaycw6f8f4.soundcloud.com/v1/events -
i trying use soundcloud widget api found here.
i have iframe
<iframe id="sciframe"></iframe
i included script
<script src="https://w.soundcloud.com/player/api.js" type="text/javascript"></script>
then, execute script in function.
var scplayer; var iframesoundcloud = document.getelementbyid("sciframe"); iframesoundcloud.src = "https://w.soundcloud.com/player/?url="+encodeuricomponent(lien); scplayer = sc.widget("sciframe"); scplayer.bind(sc.widget.events.ready, function(){ scplayer.play(); });
when page first loaded, soundcloud song plays well. when call time without refreshing page, cross-origin request blocked: same origin policy disallows reading remote resource @ https://l9bjkkhaycw6f8f4.soundcloud.com/v1/events. (reason: cors header 'access-control-allow-origin' not match '').* message, , song cannot play.
why that?
the problem iframe. generate new iframe every-time want play new song.
var framescid = "sciframe"+new date().getmilliseconds(); var iframesc = $('<iframe></iframe>'); iframesc.attr({"id":framescid, "src":"https://w.soundcloud.com/player/?url="+encodeuricomponent(lien)}); $("#sciframecontainer").html(iframesc); scplayer = sc.widget(framescid); ...
if has better way fix it. i'm waiting
Comments
Post a Comment