我正在尝试为 navigator.getUserMedia 弹出用户权限对话框,它在 iframe 的外部页面上调用。目前,示例将显示“权限被拒绝”,而不会向用户显示对话框。
这是一个用 javascript 编写的通用 Windows 应用程序。网络摄像头已添加到功能中。
我已经尝试找到类似于下面的地理定位函数的东西。但是我找不到网络摄像头的任何东西。
Windows.Devices.Geolocation.Geolocator.requestAccessAsync
代码非常简单。它是一个链接到 webRTC 示例的 x-ms-webview。
index.html
<html>
<head>
</head>
<body>
<x-ms-webview style="left: 0px; top: 0px; width: 100%; height: 100%; position: absolute;" src="https://webrtc.github.io/samples/src/content/getusermedia/gum/"></x-ms-webview>
</body>
</html>
最佳答案
You could also use PermissionRequested event to enable the webrtc feature that requires webcam capability. If you use a permission dialog, use WebViewPermissionRequest.Defer to create a WebViewDeferredPermissionRequest which can be used after user input. For more information, please refer to the following links.
https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/web-view https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/WebView
document.getElementById("webview").addEventListener("MSWebViewPermissionRequested", managePermissionRequest)
function managePermissionRequest(e) {
if (e.permissionRequest.type == "media") {
e.permissionRequest.allow();
}
}
关于javascript - 在 UWP javascript 应用程序的 iframe 中获取 getUserMedia 的用户权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40424172/