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]
});