Uncaught MissingElementError: Could not find the provided element:
at new r (v1.js:1:18275)
at v1.js:1:24676
at r [as constructor] (v1.js:1:24776)
at new r (v1.js:1:26334)
at addStream (stream.js:42:21)
at HTMLInputElement.onchange (stream.html:25:70)
WITH this js file :
var num = 0;
function addStream(element){
var checkBox = element.checked
if(checkBox){
console.log(element.id)
var options = {
channel: element.id, // TODO: Change this to the streams username you want to embed
width: 640,
height: 360,
};
var secteur = num;
//ajouterscript(element.id)
addDiv();
var player1 = new Twitch.Player(String.fromCharCode(secteur), options);
player1.addEventListener(Twitch.Player.READY, initiate(player1,String.fromCharCode(secteur)));
}else{
console.log('not'+ element.id)
}
}
function initiate(player,zone) {
player.addEventListener(Twitch.Player.ONLINE, handleOnline(player,zone));
player.addEventListener(Twitch.Player.OFFLINE, handleOffline(player,zone));
player.removeEventListener(Twitch.Player.READY, initiate(player,zone));
}
function handleOnline(player,zone) {
document.getElementById(zone).classList.remove('hide');
player.removeEventListener(Twitch.Player.ONLINE, handleOnline(player,zone));
player.addEventListener(Twitch.Player.OFFLINE, handleOffline(player,zone));
player.setMuted(false);
}
function handleOffline(player,zone) {
document.getElementById(zone).classList.add('hide');
player.removeEventListener(Twitch.Player.OFFLINE, handleOffline(player,zone));
player.addEventListener(Twitch.Player.ONLINE, handleOnline(player,zone));
player.setMuted(false);
}
function addDiv() {
var container = document.getElementById('streambox');
var nouvelleDiv = document.createElement('div');
nouvelleDiv.setAttribute('id',num);
num++;
container.appendChild(nouvelleDiv);
}
and i’m not understand, i’m a really beginner on HTML/JS so every help is cool
new Twitch.Player us trying to talk to a div of id String.fromCharCode(secteur) which equates to " " which doesn’t exist as addDiv created a div with ID of 0
Aside from that all your channel names are mostely display names rather than the login (which is all lower case) but this isn’t the problem just a side note.
and i will try to change my embed using iframe from Non-Interactive Inline Frames for Live Streams and VODs maybe less error on my code
Really thank you