Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda