LH-276: Update producer close event handler

This commit is contained in:
Sergiu Toma 2023-02-21 02:10:04 +02:00
parent 0fca614e8e
commit c47259225a
3 changed files with 6 additions and 20 deletions

14
app.js
View File

@ -487,36 +487,22 @@ peers.on('connection', async (socket) => {
- When consuming on consumerTransport, it is initially done with paused: true, here we will resume
- For the initiator we resume the initiatorConsumerAUDIO/VIDEO and for receiver the receiverConsumerAUDIO/VIDEO
*/
try {
socket.on('consumer-resume', () => {
try {
const callId = socketDetails[socket.id];
const isInitiatorValue = isInitiator(callId, socket.id);
console.log(`[consumer-resume] callId: ${callId} | isInitiator: ${isInitiatorValue}`);
if (isInitiatorValue) {
try {
videoCalls[callId].initiatorConsumerVideo && videoCalls[callId].initiatorConsumerVideo.resume();
videoCalls[callId].initiatorConsumerAudio && videoCalls[callId].initiatorConsumerAudio.resume();
} catch (error) {
console.log('sssss', error.message);
}
} else {
try {
videoCalls[callId].receiverConsumerVideo && videoCalls[callId].receiverConsumerVideo.resume();
videoCalls[callId].receiverConsumerAudio && videoCalls[callId].receiverConsumerAudio.resume();
} catch (error) {
console.log('sssss22222', error.message);
}
console.log('videoCalls[callId].receiverConsumerVideo', videoCalls[callId].receiverConsumerVideo);
console.log('videoCalls[callId].receiverConsumerAudio', videoCalls[callId].receiverConsumerAudio);
}
} catch (error) {
console.error(`[consumer-resume] | ERROR | callId: ${socketDetails[socket.id]} | isInitiator: ${isInitiator} | error: ${error.message}`);
}
});
} catch (error) {
console.log('akakakakakak', error.mesage);
}
socket.on('close-producer', ({ callId, kind}) => {
try {

View File

@ -20832,6 +20832,7 @@ const connectRecvTransport = async () => {
console.log('❗ Don\'t have AUDIO stream to consume');
}
socket.emit('consumer-resume')
remoteVideo.srcObject = stream
remoteVideo.setAttribute('autoplay', true)
@ -20839,7 +20840,6 @@ const connectRecvTransport = async () => {
remoteVideo.play()
.then(() => {
console.log('remoteVideo PLAY')
socket.emit('consumer-resume')
})
.catch((error) => {
console.error(`remoteVideo PLAY ERROR | ${error.message}`)

View File

@ -474,6 +474,7 @@ const connectRecvTransport = async () => {
console.log('❗ Don\'t have AUDIO stream to consume');
}
socket.emit('consumer-resume')
remoteVideo.srcObject = stream
remoteVideo.setAttribute('autoplay', true)
@ -481,7 +482,6 @@ const connectRecvTransport = async () => {
remoteVideo.play()
.then(() => {
console.log('remoteVideo PLAY')
socket.emit('consumer-resume')
})
.catch((error) => {
console.error(`remoteVideo PLAY ERROR | ${error.message}`)