Added webRTC error message.
This commit is contained in:
parent
9d3078bef0
commit
227458c517
3 changed files with 47 additions and 1 deletions
|
|
@ -149,6 +149,7 @@ class webRTCHandler{
|
|||
//Setup peer event handlers
|
||||
this.currentStream.addEventListener('icecandidate', this.sendIceCandidate.bind(this));
|
||||
this.currentStream.addEventListener('track', this.handleVideoStream.bind(this));
|
||||
this.currentStream.addEventListener('connectionstatechange', this.handleConnectionState.bind(this));
|
||||
|
||||
//Create offer from peerConnection
|
||||
const offer = await this.currentStream.createOffer({
|
||||
|
|
@ -258,9 +259,46 @@ class webRTCHandler{
|
|||
//clear currentViewers map
|
||||
this.currentViewers.clear();
|
||||
|
||||
//Clear errors
|
||||
this.client.player.videoContainer.innerHTML = "";
|
||||
|
||||
//Clear candidate cache
|
||||
this.cachedCandidates = [];
|
||||
}
|
||||
|
||||
handleConnectionState(data){
|
||||
if(this.currentStream.connectionState == "failed"){
|
||||
let icon = document.createElement('img');
|
||||
icon.src = "/img/rtcerror.png";
|
||||
|
||||
let title = document.createElement('h1');
|
||||
title.innerText = "WebRTC Error";
|
||||
|
||||
let text = document.createElement('p');
|
||||
text.innerText = "Looks like we're having issues connecting you to your stream. Make sure you're not behind a CGNAT or something.";
|
||||
|
||||
let link = document.createElement('a');
|
||||
link.innerText = "Click here for more info...";
|
||||
link.href = "/streamInfo";
|
||||
link.target = "_blank";
|
||||
|
||||
let textBlock = document.createElement('div');
|
||||
textBlock.appendChild(title);
|
||||
textBlock.appendChild(text);
|
||||
textBlock.appendChild(link);
|
||||
|
||||
let errorBlock = document.createElement('div');
|
||||
errorBlock.id = "web-rtc-error-block"
|
||||
errorBlock.appendChild(icon);
|
||||
errorBlock.appendChild(textBlock);
|
||||
|
||||
this.client.player.videoContainer.innerHTML = "";
|
||||
this.client.player.videoContainer.appendChild(errorBlock);
|
||||
|
||||
let towelSound = new Audio('/audio/towel.ogg');
|
||||
towelSound.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue