Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
Incoming stream not showing PeerJs

I'm trying to make a call using peerJs library. In my app, I have 2 types of users: Client and Streamer. Only clients can call to the streamers. And when the client calls, he emits only audio stream, and the streamer needs to emit audio and video stream; So what am I doing is next:

part on my Client component:

public peer;
public outGoingCall;
public incomingStream = new BehaviourSubject(null);

ngOnInit() {
  this.peer = new Peer();
}

public callToPeer(peerId, localClientStream) {
  this.outGoingCall = this.peer.call(peerId, localClientStream);
  this.outGoingCall.on('stream', (remoteStream: MediaStream) => {
      console.log('incoming stream from streamer ', remoteStream);
      // so here in console I see incoming stream and it is active;
      // but when I apply it in video tag I don't see anything! Why?
      this.incomingStream.next(remoteStream);

    });
}

HTML file for Client component:

    <div class="call-holder" *ngIf="incomingStream | async as stream">
      <video [srcObject]="stream" autoplay></video>
    ...
    </div>

here code of Streamer component:

public peer;
public clientsCall;
public incomingClientsStream = new BehaviourSubject(null);

ngOnInit() {
  this.peer = new Peer('streamer-1'); // exact id for this streamer;

  this.peer.on('call', (mediaCon) => {
      console.log('incoming call from Client');

      // Allow only a single media
      if (this.clientsCall && this.clientsCall.open) {
        mediaCon.close();
      }

      mediaCon.on('stream', (streamFromClient: MediaStream) => {
        console.log('stream from client ', streamFromClient);
        this.incomingClientsStream.next(streamFromClient);
      });

      mediaCon.on('close', (some) => {
        console.log(some);
        console.log('client closed connections');
      });

      this.clientsCall = mediaCon;
    });
}

public answerTheCall() {
  navigator.mediaDevices.getUserMedia({audio: true, video: true})
    .then((localStream) => this.clientsCall.answer(localStream));
}

in streamers HTML file I listen the audio that comes from client and it works:

<div *ngIf="(incomingStream | async) as clientStream">
      <audio [srcObject]="clientStream" autoplay></audio>
    </div>

So the thing is, when I answer the call from a client and sending to him my local stream, I can see it from the Streamer's page but not on the Clients page. Why? Why I don't receive stream from streamer?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda