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

206
Views
Replace webrtc track of different kind without renegotiations

I am working on a project in which we are using an audio call feature of WebRTC. Audio call works fine. On button click we need to enable share screen and replaceTracks with share screen track only, but replaceTrack web api replaces tracks of same kind, for example audio track can only be replaced with audio track or video track can only be replaced with video track. In my case, I am trying to achieve two things: #1: I want to enable share screen while the audio track is on. #2: If I can replace the audio track with share screen track appended in it without renegotiations.

Please check the code :-

 (async () => {
        try {
            await navigator.mediaDevices.getDisplayMedia(
                {
                    cursor: true
                }).then(stream => {
                    let videoTrack = stream.getVideoTracks()[0];
                    var senders = peerConn.getSenders();
                    var sender = senders.find(function (s) {
                        return s.track.kind == videoTrack.kind;
                    });
                    sender.replaceTrack(videoTrack);
                    videoTrack.onended = function () {
                        sender.replaceTrack(localStream.getTracks()[1]);
                    }
                });
        } catch (err) {
            console.log('(async () =>: ' + err);
        }
    })();

In this s.track.kind is audio and videoTrack.kind is video. sender.replaceTrack(videoTrack) gives error as it replace track of same kind

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!