function callPeer(id: string) {
const peer = initializePeerInstance({ initiator: true, stream: stream! });
peer.on("signal", (data: any) => {
socket.current.emit("callUser", {
userToCall: id,
signalData: data,
from: yourID,
});
});
peer.on("stream", (stream: any) => {
if (partnerVideo.current) {
partnerVideo.current.srcObject = stream;
}
});
socket.current.on("callAccepted", (signal: any) => {
setCallAccepted(true);
peer.signal(signal);
});
}
function acceptCall() {
setCallAccepted(true);
const peer = initializePeerInstance({ initiator: false, stream: stream! });
peer.on("signal", (data: any) => {
socket.current.emit("acceptCall", { signal: data, to: caller });
});
peer.on("stream", (stream: any) => {
if (partnerVideo.current) partnerVideo.current.srcObject = stream;
});
peer.signal(callerSignal);
}
i have to functions: callPeer and acceptCall but when on('stream') is triggered i succesfully get stream and can set it to ref.current.srcObj but the video that accepts this ref doesn't display anything. It works in Firefox but not in Chrome or any other browser, i have no idea where is the problem. Tried different approaches to set video.srcObj=stream but not working