2016-04-24 96 views
5

我目前正在使用WebRTC使用VoIP。這將是一個用JavaScript編寫的UWP應用程序。RTCPeerConnection在Microsoft Edge中工作嗎?

現在,我試圖通過在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 

那麼,應該怎麼解決呢? Adapter.js也被稱爲。我也允許它需要的一切。

或者我不應該在這個項目中使用WebRTC。如果是這樣,我應該使用什麼?

乾杯!

+0

看起來像你的攝像頭/麥克風的問題。檢查navigator.mediaDevices.enumerateDevices的輸出使用[此演示](https://webrtc.github.io/samples/src/content/devices/input-output/) –

回答

9

Microsoft Edge實現了ORTC,它是WebRTC的一個更底層的分散式表親,它沒有一個總體上的RTCPeerConnection對象。

但是好消息是,adapter.js,官方WebRTC填充,在Edge上爲您填補了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;
<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>

相關問題