I would like to receive help to add group video streaming to the bellow code, i would like to implement a group streaming which ll be working with a link like
domain.net/video.html?id=123&host=1 domain.net/video.html?id=456&host=1 to allow friends joining using param id.
'use strict';
// Put variables in global scope to make them available to the browser console.
const constraints = window.constraints = {
audio: true,
video: true
};
function handleSuccess(stream) {
const video = document.querySelector('video');
const videoTracks = stream.getVideoTracks();
window.stream = stream;
video.srcObject = stream;
}
function handleError(error) {
if (error.name === 'ConstraintNotSatisfiedError') {
const v = constraints.video;
console.log("The resolution not supported");
} else if (error.name === 'PermissionDeniedError') {
console.log('Permissions have not been granted');
}
console.log(`getUserMedia error: ${error.name}`, error);
}
async function init(e) {
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
handleSuccess(stream);
e.target.disabled = true;
} catch (e) {
handleError(e);
}
}
document.querySelector('#showVideo').addEventListener('click', e => init(e));
Am in my learning stages to JavaScript please help, thanks.