简体   繁体   English

WebRTC onicecandidate 没有在 cordova android 中被调用,但在浏览器中被调用

[英]WebRTC onicecandidate not getting called in cordova android, but is getting called in browser

I am working on a file sharing project which works on WebRTC, Cordova and Framework7.我正在开发一个文件共享项目,该项目适用于 WebRTC、Cordova 和 Framework7。 My code works perfectly fine in a browser but whenever I try to run the same code through an android emulator with Cordova the WebRTC onicecandidate function never seems to get called and I don't get any error messages. My code works perfectly fine in a browser but whenever I try to run the same code through an android emulator with Cordova the WebRTC onicecandidate function never seems to get called and I don't get any error messages. If possible I don't want to use any third party libraries and just reuse the same javascript code I already wrote.如果可能的话,我不想使用任何第三方库,而只是重用我已经编写的相同 javascript 代码。

function createPeerConn() {
let conf = {
    iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
};
myConn = new RTCPeerConnection(conf, { optional: [] });
myConn.onicecandidate = function (event) {
    if (event.candidate) {
        socket.emit("candidate", event.candidate);
        console.log("create peer con called.")
    }
};
openDataChannel();
} 

That would be because RTCIceServers.urls is not supported by ANDROID Webview as per https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/urls那是因为RTCIceServers.urls不支持 RTCIceServers.urls 根据https://developer.mozilla/API/ceServer/urls/docs/RTCIceServers/

The issue was that I still had the cordova-webrtc plugin installed which seemed to switch around some scopes.问题是我仍然安装了 cordova-webrtc 插件,它似乎在某些范围内切换。 After removing this plugin everything works as expected.删除此插件后,一切都按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM