1

The goal is to capture the streams from an <audio> element and the local microphone both of which are on the peer (non-initiator), then concurrently transmit them to the initiator who is only transmitting their local microphone audio.

I have tried using both {streams: [stream_1, stream_2]} in the Peer() constructor and peer.addStream(stream_2) after the session is connected to no avail. I tested both streams individually and they work as expected. The result of the following code is only the remote_stream is transmitted back to the initiator. If I remove remote_stream from the array then the local_stream is sent.

initiator:

let local_stream = await navigator.mediaDevices.getUserMedia({
  video: false,
  audio: true
});

const initiator = new Peer({
  initiator: true,
  trickle: false,
  streams: [local_stream]
});

peer:

// this is referencing an <audio> element
let remote_stream = window.mediaTech.stream; 

let local_stream = await navigator.mediaDevices.getUserMedia({
  video: false,
  audio: true
});

const peer = new Peer({
  trickle: false,
  streams: [local_stream, remote_stream]
});
Chris Newell
  • 137
  • 2
  • 10
  • How is `window.mediaTech.stream` referencing an ` – guest271314 Feb 28 '19 at 02:19
  • @guest271314 - like this: `window.mediaTech.stream = document.getElementById("remote-audio").captureStream();` and `` – Chris Newell Feb 28 '19 at 02:43
  • Is simple-peer a library? Are you trying to merge the two streams or send two streams separately? – guest271314 Feb 28 '19 at 07:18
  • Yeah, its a library [link](https://github.com/feross/simple-peer) I was really just trying to get both streams from the peer to the initiator. For now the workaround is to mix the audio on the peer (using the Web Audio API) before sending it to the initiator. – Chris Newell Feb 28 '19 at 18:09

0 Answers0