RTCPeerConnection在Microsoft Edge中有效吗?

Tha*_*ith 9 javascript voip webrtc win-universal-app microsoft-edge

我目前正在使用WebRTC进行VoIP.它将是一个用JavaScript编写的UWP应用程序.

现在,我试图通过测试Microsoft Edge上的https://webrtc.github.io/samples中的示例来检查它是否有效.

事实证明它除了 工作正常RTCPeerConnection.

例如,当我在Edge中打开https://webrtc.github.io/samples/src/content/peerconnection/audio时,它getUserMedia() error: NotFoundError在我点击呼叫按钮时给了我.在Chrome上,它运行正常.

另一个例子是当我尝试https://apprtc.appspot.com时,它给了我

Messages:  
Error getting user media: null
getUserMedia error: Failed to get access to local media. Error name was NotFoundError. Continuing without sending a stream.
Create PeerConnection exception: InvalidAccessError

Version:    
gitHash:    c135495bc71e5da61344f098a8209a255f64985f
branch:     master
time:       Fri Apr 8 13:33:05 2016 +0200
Run Code Online (Sandbox Code Playgroud)

那么,我该如何解决这个问题呢?Adapter.js也被称为.我也允许它需要的一切.

或者我不应该将WebRTC用于此项目.如果是这样,我应该使用什么?

干杯!

jib*_*jib 12

Microsoft Edge实现了ORTC,这是WebRTC的一个更低级别的分散表兄,它没有一个总体RTCPeerConnection对象.

但好消息是,适用于Edge 的官方WebRTC polyfill adapter.js,RTCPeerConnection因此您应该能够在所有浏览器上以相同的方式使用WebRTC.

例如,这个演示适用于Edge,Firefox和Chrome.

var pc1 = new RTCPeerConnection(), pc2 = new RTCPeerConnection();

navigator.mediaDevices.getUserMedia({ video: true, audio: true })
  .then(stream => pc1.addStream(video1.srcObject = stream))
  .catch(log);

var add = (pc, can) => can && pc.addIceCandidate(can).catch(log);
pc1.onicecandidate = e => add(pc2, e.candidate);
pc2.onicecandidate = e => add(pc1, e.candidate);

pc2.onaddstream = e => video2.srcObject = e.stream;
pc1.oniceconnectionstatechange = e => log(pc1.iceConnectionState);
pc1.onnegotiationneeded = e =>
  pc1.createOffer().then(d => pc1.setLocalDescription(d))
  .then(() => pc2.setRemoteDescription(pc1.localDescription))
  .then(() => pc2.createAnswer()).then(d => pc2.setLocalDescription(d))
  .then(() => pc1.setRemoteDescription(pc2.localDescription))
  .catch(log);

var log = msg => div.innerHTML += "<br>" + msg;
Run Code Online (Sandbox Code Playgroud)
<video id="video1" width="160" height="120" autoplay muted></video>
<video id="video2" width="160" height="120" autoplay></video><br>
<div id="div"></div>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
Run Code Online (Sandbox Code Playgroud)