From c47259225aed485939370dfb9907eb6caae0ab1e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 21 Feb 2023 02:10:04 +0200 Subject: [PATCH] LH-276: Update producer close event handler --- app.js | 14 -------------- public/bundle.js | 6 +++--- public/index.js | 6 +++--- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/app.js b/app.js index 97a5dc3..2e1ce3f 100644 --- a/app.js +++ b/app.js @@ -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 { diff --git a/public/bundle.js b/public/bundle.js index 8daefb8..408be6d 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20832,14 +20832,14 @@ const connectRecvTransport = async () => { console.log('❗ Don\'t have AUDIO stream to consume'); } - + socket.emit('consumer-resume') + remoteVideo.srcObject = stream remoteVideo.setAttribute('autoplay', true) - + remoteVideo.play() .then(() => { console.log('remoteVideo PLAY') - socket.emit('consumer-resume') }) .catch((error) => { console.error(`remoteVideo PLAY ERROR | ${error.message}`) diff --git a/public/index.js b/public/index.js index 16c7387..6c5f71a 100644 --- a/public/index.js +++ b/public/index.js @@ -474,14 +474,14 @@ const connectRecvTransport = async () => { console.log('❗ Don\'t have AUDIO stream to consume'); } - + socket.emit('consumer-resume') + remoteVideo.srcObject = stream remoteVideo.setAttribute('autoplay', true) - + remoteVideo.play() .then(() => { console.log('remoteVideo PLAY') - socket.emit('consumer-resume') }) .catch((error) => { console.error(`remoteVideo PLAY ERROR | ${error.message}`)