Add visual feedback for connection status.
This commit is contained in:
@@ -196,6 +196,10 @@ h1 {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.media-failed {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
height: 2em;
|
height: 2em;
|
||||||
|
|||||||
@@ -530,6 +530,7 @@ function setMedia(id) {
|
|||||||
|
|
||||||
media.srcObject = c.stream;
|
media.srcObject = c.stream;
|
||||||
setLabel(id);
|
setLabel(id);
|
||||||
|
setMediaStatus(id, false);
|
||||||
|
|
||||||
resizePeers();
|
resizePeers();
|
||||||
}
|
}
|
||||||
@@ -545,6 +546,19 @@ function delMedia(id) {
|
|||||||
resizePeers();
|
resizePeers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setMediaStatus(id, good) {
|
||||||
|
let media = document.getElementById('media-' + id);
|
||||||
|
if(!media) {
|
||||||
|
console.warn('Setting status of unknown media.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(good)
|
||||||
|
media.classList.remove('media-failed');
|
||||||
|
else
|
||||||
|
media.classList.add('media-failed');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function setLabel(id, fallback) {
|
function setLabel(id, fallback) {
|
||||||
let label = document.getElementById('label-' + id);
|
let label = document.getElementById('label-' + id);
|
||||||
if(!label)
|
if(!label)
|
||||||
@@ -725,6 +739,12 @@ async function gotOffer(id, labels, offer) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pc.oniceconnectionstatechange = e => {
|
||||||
|
setMediaStatus(id,
|
||||||
|
pc.iceConnectionState === 'connected' ||
|
||||||
|
pc.iceConnectionState === 'completed');
|
||||||
|
}
|
||||||
|
|
||||||
c.pc.ontrack = function(e) {
|
c.pc.ontrack = function(e) {
|
||||||
let label = e.transceiver && c.labelsByMid[e.transceiver.mid];
|
let label = e.transceiver && c.labelsByMid[e.transceiver.mid];
|
||||||
if(label) {
|
if(label) {
|
||||||
@@ -1178,6 +1198,9 @@ async function newUpStream(id) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pc.oniceconnectionstatechange = e => {
|
pc.oniceconnectionstatechange = e => {
|
||||||
|
setMediaStatus(id,
|
||||||
|
pc.iceConnectionState === 'connected' ||
|
||||||
|
pc.iceConnectionState === 'completed');
|
||||||
if(pc.iceConnectionState === 'failed') {
|
if(pc.iceConnectionState === 'failed') {
|
||||||
try {
|
try {
|
||||||
pc.restartIce();
|
pc.restartIce();
|
||||||
|
|||||||
Reference in New Issue
Block a user