if (numberOnline > 0) {
var actualStream = onlineUsers.data[0].user_name;
}
player.setChannel(actualStream);
is wrong
I also made a couple of other fixes
https://twitch.extensions.barrycarlyon.co.uk/temp/test_24323_b.html
Notably how the URL’s are constructed (using a join instead of a string replace)
Your setInterval was also variable trashing… For some reason you were extracting the users ID’s and overwriting the users name array to be user_id’s instead breaking follow up calls. So I commented that section out. Not sure your intent there. You swap the names out for ID’s and then it’s all broken. Either start with ID’s or names, don’t convert mid way thru the life of the program
You also do nothing to stop the channel changing if the channel is the same and/or if more than one channel is live. It’ll change channel 5 times every 6 seconds if all 5 channels are live.
Consider something like
var live = [];
if (numberOnline > 0) {
live.push(onlineUsers.data[0].user_name);
}
if (live[0]) {
player.setChannel(live[0]);
}