Autoplay=false not working when embedding stream via script

Hey,
i wanna work with the “new” embedding option via the javascript and ended in an autoplay false problem.

this is my script:

<script type="text/javascript">
$(document).ready(function(){
      
		
	  var embedtop = new Twitch.Embed("twitch_stream", {
	  autoplay: false,
        width: "100%",
        height: 210,
		layout: "video",	
        channel: "hireztv" // for example
      });
	  });
    </script>

so why is the api ignoring the autoplay false. even if i add a event listender like:

embedtop.addEventListener(Twitch.Embed.VIDEO_READY, () => {
       var player = embedtop.getPlayer();
	   player.pause();
      });

the player shows 1 or 2 seconds a paused stream and then starts playing.
Seems like there is an override, but its not from my side. there is no other “autoplay” option in my code.

EDIT:
Hey again :slight_smile:
i made a JSbin with the same code i use. nothing more.
whats wrong with it? and if its a bug , does anyone know a workaround?

jsbint

just wait about 10 seconds, and the video starts … i dont want that !

You can uncomment the eventlistener with player pause and you will see that the stream starts imediatly . even with autoplay false ! oO

EDIT:
Okay, maybe someone is new to the twitch api like i am and has the same question / problem.
The autoplay option is only for videos from twitch with the “embed” api

You need to use the player api:

its a little bit more on the bottom of the twitch dev docs. then you can use autoplay false to a stream. Works now like a charm :slight_smile:

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