How to addTrack in MediaStream in WebRTC

Update: working example near bottom. This depends greatly on which browser you are using at the moment, due to an evolving spec. In the specification and Firefox, peer connections are now fundamentally track-based, and do not depend on local stream associations. You have var sender = pc.addTrack(track, stream), pc.removeTrack(sender), and even sender.replaceTrack(track), the latter involving … Read more