API-Examples-Web icon indicating copy to clipboard operation
API-Examples-Web copied to clipboard

change audio source input on the fly!

Open Abdeladim101Basraoui opened this issue 2 years ago • 0 comments
trafficstars

in my current scenarion I want to have the ability to change the audioTracks on the fly I found on the documentation that it's possible to do so for the audio Track ,but couldn't find resource for audio tracks ,I've been using webRTC native api and I did a solution to

  peerConnection.removeTrack(oldSender);

  const newSender = peerConnection.addTrack(track, stream);

  const localSdp = await peerConnection.createOffer({ offerToReceiveAudio: 1 });
  await peerConnection.setLocalDescription(reply);

  const response = await sendOffer(peerConnection.localDescription);

  const description = new RTCSessionDescription(response);
  peerConnection.setRemoteDescription(description);

  return newSender;
}

thank you

Abdeladim101Basraoui avatar Sep 05 '23 19:09 Abdeladim101Basraoui