Get Access to Width and Height variables after creation of an Embed Player

I’m very new to javascript and i was trying to access the width and height values of an Iframe to modify them depending on the window Size. For some reasons it didn’t work and all solutions went nowhere.

Then i thought “hey there’s also a direct javascript implementation”.

Setting the Width and Height of the player on load is child play but when it comes to dynamically resize it depending on window size i hit a wall. because in the Embed Dev Post there is no such access. So i was wondering if that access actually exist Or if it’s just not implemented.

That would be something like

var w = window.innerWidth;
var h = window.innerHeight;
var options = {
width: w,
height: h,
channel: “monstercat”
};
twitch = new Twitch.Player(“SamplePlayerDivID”, options);

That first part works perfectly

And then in the onresize event i would like to have something like

twitch.setWidth (w);
twitch.setHeight(h);

SO i found the solution myself by editing my post and my stuff XD.

THERE IS a twitch.setWidth and twitch.setHeight. Just not in the doc.

You have to use Twitch.Player and not Twitch.Embed though or it won’t work.

Might be clever to add it ^^.

window.onresize=function resizeFunction(){
w = window.innerWidth;
h = window.innerHeight;
twitch.setWidth(w);
twitch.setHeight(h);
}

here is the code i’m using

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