mslosarz / nextrtc-example-videochat

Most simple example of use NextRTC (WebRTC signaling server written in java) where two people can setup video call (treat it like prototype!)
https://videochat.nextrtc.org/
MIT License
37 stars 19 forks source link

video number is Incorrect #26

Open lishidetainan opened 5 years ago

lishidetainan commented 5 years ago

when I open more than four web client, I join the same conversation, the last client show the video number more than four.

emreokutan commented 5 years ago

hi i think i found the issue; beacuse of this line in nextrtc.js remoteConnection.ontrack = e => this.onRemoteStream(connectionName, e.streams); the ontrack event handler fires twice, if the remotestream has both audio and video (so i assume that you changed the audio:false to audio:true :) just like me )

but as the orijinal git example has audio: false i think msolarez has missed this situation. so i think thats the problem but how to resolve this?

Maybe this could be;

        nextRTC.on('remoteStream', function (stream) {

        var dest = $('#'+stream.member);
        if(dest.length==0 ) {
              dest = $("#template").clone().addClass('remotestream').prop({id: stream.member});
              $("#container").append(dest);
              dest[0].srcObject = stream.stream;
        } else {
              dest[0].srcObject = stream.stream;
        }

        });