I am trying to use the Soundcloud widget API found here.
I have my Iframe
<iframe id="SCIframe"></iframe
I included the script
<script src="https://w.soundcloud.com/player/api.js" type="text/javascript"></script>
Then, I execute this script in a 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 the page first loaded, the soundcloud song plays well. But when I call it another time without refreshing the page, I get Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://l9bjkkhaycw6f8f4.soundcloud.com/v1/events. (Reason: CORS header 'Access-Control-Allow-Origin' does not match '').* message, and the song cannot play.
Why is that?