Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
how to switch from shared screen to camera again with RTCMultiConnection

I need to switch from share Screen to video again. I first use this code to share the screen. connection.addStream ({ screen: true, oneway: true, streamCallback: function (screen) { addStreamStopListener (screen, function () { selectFrontCameraDuringActiveSession (); }); }, })

and then I use this code to show the video I'm doing wrong again.

    connection.attachStreams.forEach (function (stream) {
      // stop only video tracks
      // so that we can recapture video track
      stream.getVideoTracks (). forEach (function (track) {
        track.stop ();
      });
    });

    var mediaConstraints = {
      audio: false, // NO need to capture audio again
      video: {
        facingMode: "application",
      },
    };

    navigator.mediaDevices
      .getUserMedia (mediaConstraints)
      .then (function (frontCamera) {
        var frontCameraTrack = frontCamera.getVideoTracks () [0];
        //video.srcObject = frontCamera;
        connection.getAllParticipants (). forEach (function (pid) {
          connection.peers [pid] .peer
            .getSenders ()
            .forEach (function (sender) {
              if (sender.track.kind == "video") {
                sender.replaceTrack (frontCameraTrack);
              }
            });
        });
        app.toggleShareScreen = false;
      });

Everyone who listens gets the change. but the one who transmits the change is not reflected. and turning off video and activating video for example stops working.

        if (value === false) {
          connection.attachStreams.forEach (function (stream) {
            stream.getVideoTracks (). forEach ((t) => (t.enabled = value));
          });
        }
        if (value === true) {
          connection.attachStreams.forEach (function (stream) {
            stream.getVideoTracks (). forEach ((t) => (t.enabled = value));
          });
        }
 
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!