V5 for Interactive embeds

I have a question: previously I’ve used https://player.twitch.tv/js/embed/v1.js to get interactive embeds. But I’m seeing that now V5 is available. How can I get interactive iframes with the latest version, since the other one will be deprecated (or it is already).

Thanks in advance

The version in the interactive embed script URL does not correspond to the API version. The URL is still correct and the one to use. See API v5 interactive embed docs.

Got it. I didn’t see the script reference there. Thanks.

And last question: can I use the play() method immediately without any issues after the player instantiation?

<script src= "http://player.twitch.tv/js/embed/v1.js"></script>
<div id="<player div ID>"></div>
<script type="text/javascript">
var options = {
	width: <width>,
	height: <height>,
	channel: "<channel ID>",
	video: "<video ID>",
	collection: "<collection ID>",
var player = new Twitch.Player("<player div ID>", options);

I’ve tried without success. My test is on this Fiddle: Edit fiddle - JSFiddle - Code Playground

If there’s a way, any hints will be appreciated it. Thanks

Use the event listeners to check when the player is ready.

player.addEventListener(Twitch.Player.READY, _ => player.play());

I tried what you stated above but still I see errors coming

See https://jsfiddle.net/a6m5s0np/1/

The video ID needs to be prepended with a v v109.... Works fine after adding that one letter.

Thanks. I forgot about that.

@3ventic And what if the autoplay attribute is set to false? That way not even with the READY event works.
See https://jsfiddle.net/a6m5s0np/2/

Not sure, but why would you set autoplay false if you want to play it automatically?

@3ventic Because I want to get the player ready and then, if a flag is passed by my code, it can be played. Otherwise, it won’t

Would it be possible to set the autoplay true/false based on that flag instead?

@3ventic Unfortunately, it is not possible. I have to set it up autoplay: false and then the flag might be set by the user so it has to be ready that way. Isn’t there another alternative for this?

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