peerjs icon indicating copy to clipboard operation
peerjs copied to clipboard

Member of videochat can't see anybody If he doesn't have a webcam

Open Licege opened this issue 3 years ago • 4 comments

Hello, I have a some problem with video tracks. If user doesn't have a webcam or deny permission in browser than he don't receive video tracks from another users (which send video). I can fix it only if I change options which passed in offer like that:

const offer = await peerConnection.createOffer(
  { ...this.connection.options.constraints, offerToReceiveAudio: true, offerToReceiveVideo: true }
);

Licege avatar Apr 14 '22 11:04 Licege

Hey @Licege. Thanks for the report!

Can you post a minimal working example of this? I would like to reproduce this.

Also, please add:

  • Browser vendor and version
  • OS vendor and version
  • PeerJS version
  • do you use a bundler?

jonasgloning avatar Apr 15 '22 10:04 jonasgloning

Hello, I added simple example here https://github.com/Licege/peerjs-bug

Browser: Chrome (100.0.4896.127); OS: Mac OS Big Sur 11.6 (but try also Windows 10); PeerJS: 1.3.2; Yes we use webpack)

Licege avatar Apr 26 '22 19:04 Licege

@Licege I have faced with this bug i fixed it by this code:

static createBlankVideoTrack(opts = {}) {
        const { width = 1920, height = 1080 } = opts

        const canvas = Object.assign(document.createElement("canvas"), {
            width,
            height,
        })

        canvas.getContext("2d").fillRect(0, 0, width, height)

        const stream = canvas.captureStream()

        return stream
    }
    ...
    const audioTrack = stream.getAudioTracks()[0]

     const videoStream = UserMedia.createBlankVideoTrack()

    videoStream.addTrack(audioTrack)

     stream = videoStream

just create blank video track and add an audio track from the main stream

undermuz avatar May 11 '22 13:05 undermuz