Can I change the current MediaStream? #1253
-
Hello, Can I change the currently ongoing media stream? //_peerConnection.removeTrack(_videoTrack); Removing the previous track would stop the stream altogether. Running the code as above will continue streaming the previously started stream. What am I doing wrong please? Renegociation is not needed because the 2 videos are of same resolution and use the same codec. Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
If your from:
To
|
Beta Was this translation helpful? Give feedback.
-
It will always play the last track added(_peerConnection.addTrack) before the stream starts and cannot be modified afterwards. If I try your way it will work only for the added track and when I try to play the other track it will simply not send anything. If it's working for you could you please provide a code sample? Thank you. |
Beta Was this translation helpful? Give feedback.
All good 👍
This is possible, the receiving WebRTC implementation would also need to do the switching of the track being selected by the user in case of a single view.
If it's a browser, usually you will change the video element source to the selected MediaStream and then pause the other streams.
If it's a multi-view at once, then set the video element to the corresponding MediaStreams.