【问题标题】:Why are WebRTC methods missing when run within a Microsoft.Toolkit.Forms.UI.Controls.Webview?为什么在 Microsoft.Toolkit.Forms.UI.Controls.Webview 中运行时缺少 WebRTC 方法?
【发布时间】:2020-11-02 21:06:24
【问题描述】:

在 .NET Framework 4.6.2 Windows 应用程序中,我尝试在 WebView 控件中以 JavaScript 运行一些 WebRTC 功能。该控件来自 Microsoft.Toolkit.Forms.UI.Controls.Webview (v6.1.1)。

当我尝试使用 RTCPeerConnection.AddTransceiver()RTCPeerConnection.GetTransceivers() 时,我收到以下错误: Object doesn't support property or method 'addTransceiver'

直接在 Edge 中运行时,代码按预期执行。

为什么会有差异,我如何才能看到在 WebView 控件上下文中使用的确切 API?

【问题讨论】:

    标签: javascript .net webrtc webbrowser-control microsoft-edge


    【解决方案1】:

    您使用的是哪个版本的 Edge 浏览器?我假设您使用的是 Edge Chromium,因此 API 可以在浏览器中正常运行。

    RTCPeerConnection.addTransceiver()browser compatibility可以看出,它只支持Edge Chromium。 Webview控件使用EdgeHTML作为Edge Legacy引擎的渲染引擎,所以不能在WebView中使用API​​。我也试过RTCPeerConnection.GetTransceivers(),它也不支持Edge Legacy。

    如果您想在 Microsoft Edge webview 控件中使用 API,我建议您使用 WebView2,它使用 Microsoft Edge Chromium 作为渲染引擎,在本机应用程序中显示 Web 内容。

    【讨论】:

    • 我不知道 Mozilla 文档中的那些兼容性图表。非常好。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-02
    • 2017-03-31
    • 1970-01-01
    • 2011-04-03
    相关资源
    最近更新 更多