Soundcloud Embed: Uncaught TypeError: Layer must be a node document

I have a Rails application that uses soundcloud built-in players. The player loads in an iframe, which includes the main rails view containing html used to load the player:

<iframe width="100%" height="300" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<%= @id %>&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;visual=true"></iframe>

From time to time, when the site loads, the player does not render, and we get the following error:

Uncaught TypeError: Layer must be a document node

d          @ widget-6dc4a288.js:21

We also tried replacing raw html with js code on sc sdk, but still experienced the same error:

<script src="//connect.soundcloud.com/sdk-2.0.0.js"></script>
<script>
  SC.initialize({
    client_id: "<%= SECRET_KEY %>"
  });
  SC.oEmbed("<%= @id %>", {auto_play: true, height: 300}, function(oembed){
    document.getElementById('video-container').innerHTML = oembed.html;
  });
</script>

Does anyone know the source of this error? It seems that about 1/4 times we are trying to display the player.

+4
source share

All Articles