Maa*_*ers 5 javascript iframe webrtc win-universal-app uwp
我试图让 navigator.getUserMedia 弹出用户权限对话框,该对话框在 iframe 的外部页面上调用。目前,该示例将显示“权限被拒绝”,而不会向用户显示对话框。
这是一个用 JavaScript 编写的通用 Windows 应用程序。网络摄像头已添加到功能中。
我尝试找到类似于下面的地理定位功能的东西。但我找不到网络摄像头的任何内容。
Windows.Devices.Geolocation.Geolocator.requestAccessAsync
Run Code Online (Sandbox Code Playgroud)
代码非常简单。它是一个链接到 webRTC 示例的 x-ms-webview。
索引.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>
Run Code Online (Sandbox Code Playgroud)
您还可以使用 PermissionRequested 事件来启用需要网络摄像头功能的 webrtc 功能。如果使用权限对话框,请使用 WebViewPermissionRequest.Defer 创建一个可在用户输入后使用的 WebViewDeferredPermissionRequest。欲了解更多信息,请参阅以下链接。
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();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2708 次 |
| 最近记录: |