'Accessing web camera in WebView2 from Local html/js file
I have created a Javacsript which access Web Camera and it works fine in Chrome and Edge . And also works fine WPF with WeBView2 . But I try to use same javascript in UWP with WebView2 then nothing works , looks like permission issue in webview2 for my local Htmlfile .
I tried below code (someone posted ) but it has also not worked
if (wv2.CoreWebView2 != null)
{
wv2.CoreWebView2.SetVirtualHostNameToFolderMapping(
"appassets.example1", "Assets",
Microsoft.Web.WebView2.Core.CoreWebView2HostResourceAccessKind.DenyCors);
try
{
wv2.Source = new Uri("http://appassets.example1/camera.html");
}
catch (Exception ex)
{
}
}
How can I give permission or map properly in in UWP? My html file is in Assets folder:
C:\Users\xyz\Documents\uwp_LiveVideo_Blur\uwp_LiveVideo_Blur\Assets\cam.html
Solution 1:[1]
Accessing web camera in WebView2 from Local html/js file
We suggest you access web camera with WebView2 control. It will provide a better experience. For accessing camera In UWP platfrom, you need enable Webcam capability in package mainifest file like Shawn Ramirez mentioned above.
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="webcam"/>
</Capabilities>
Please note if your web page use window.external.norify method, you must include the page's URI in the ApplicationContentUriRules section of the app manifest.for more please refer to Interacting with web view content
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
