Function not recognizing when embedding videos

I’m following the guide here.

In fact, I’ve copied the code as it is, saved it as an HTML file and run it.

The console says embed.getPlayer() is not a function.

On top of this, the video auto-plays even though its not supposed to.

Embed is the name of your JavaScript object? Can you post the code?

<html>
<!-- Load the Twitch embed script -->
<script src="https://embed.twitch.tv/embed/v1.js"></script>

<!--
  Create a Twitch.Embed object that will render
  within the "twitch-embed" root element.
-->
<script type="text/javascript">
  var embed = new Twitch.Embed("twitch-embed", {
    width: 854,
    height: 480,
    channel: "monstercat",
    layout: "video",
    autoplay: false
  });

  var player = embed.getPlayer();
  player.addEventListener(Twitch.Player.PLAY, function() {
    changeAdvertisementBanner();
  });
  player.play(); 
</script>

Taken from here

Please surround your code in lines of 3 backticks like below so we can read it all (some of the html tags were processed by the forum software by mistake now).

```
// code here
```

It looks like you’re missing the <div id="twitch-embed"></div> from yours though.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.