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,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}`)

View File

@ -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}`)