@@ -64,82 +64,6 @@ var environment = await CoreWebView2Environment.CreateAsync(
6464OnCreateEnvironmentCompleted(environment);
6565```
6666
67- ### C++ Sample
68- ``` cpp
69- using namespace Microsoft ::WRL;
70-
71- ScenarioWebRtcUdpPortConfiguration::ScenarioWebRtcUdpPortConfiguration(AppWindow* appWindow)
72- : m_appWindow(appWindow), m_webView(appWindow->GetWebView())
73- {
74- // Navigate to a demo page that will trigger WebRTC usage.
75- m_demoUri = L"https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/";
76- CHECK_FAILURE (m_webView->Navigate(m_demoUri.c_str()));
77-
78- // If we navigate away from the demo page, turn off this scenario.
79- CHECK_FAILURE(m_webView->add_ContentLoading(
80- Callback<ICoreWebView2ContentLoadingEventHandler>(
81- [this](ICoreWebView2* sender, ICoreWebView2ContentLoadingEventArgs* /*args*/)
82- -> HRESULT
83- {
84- wil::unique_cotaskmem_string uri;
85- sender->get_Source(&uri);
86- if (uri.get() != m_demoUri)
87- {
88- m_appWindow->DeleteComponent(this);
89- }
90- return S_OK;
91- })
92- .Get(),
93- &m_contentLoadingToken));
94- }
95-
96- ScenarioWebRtcUdpPortConfiguration::~ ScenarioWebRtcUdpPortConfiguration()
97- {
98- CHECK_FAILURE(m_webView->remove_ContentLoading(m_contentLoadingToken));
99- }
100-
101- ```
102- ### C# Sample
103- ```csharp
104- using Microsoft.Web.WebView2.Core;
105- using System;
106-
107- class ScenarioWebRtcUdpPortConfiguration
108- {
109- private readonly AppWindow _appWindow;
110- private readonly CoreWebView2 _webView;
111- private readonly string _demoUri;
112- private EventRegistrationToken _contentLoadingToken;
113-
114- public ScenarioWebRtcUdpPortConfiguration(AppWindow appWindow)
115- {
116- _appWindow = appWindow;
117- _webView = appWindow.GetWebView();
118-
119- // Navigate to a demo page that will trigger WebRTC usage.
120- _demoUri = "https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/";
121- _webView.Navigate(_demoUri);
122-
123- // If we navigate away from the demo page, turn off this scenario.
124- _webView.ContentLoading += WebView_ContentLoading;
125- }
126-
127- private void WebView_ContentLoading(object? sender, CoreWebView2ContentLoadingEventArgs e)
128- {
129- var uri = _webView.Source;
130- if (uri != _demoUri)
131- {
132- _appWindow.DeleteComponent(this);
133- }
134- }
135-
136- ~ScenarioWebRtcUdpPortConfiguration()
137- {
138- _webView.ContentLoading -= WebView_ContentLoading;
139- }
140- }
141- ```
142-
14367# API Details
14468## C++
14569```
0 commit comments