Maarten Manders Maarten Manders - 1 year ago 124
Javascript Question

Get user permission for getUserMedia in iframe within a UWP javascript app

I'm trying to get the user permission dialog to pop up for navigator.getUserMedia, which is called on an external page in an iframe. Currently the sample will show "Permission denied" without ever having presented a dialog to the user.

This is a universal Windows app written in javascript. The webcam has been added to the capabilities.

I've tried finding something similar to the geolocation function below. But I could not find anything for the webcam.


The code is very simple. It is an x-ms-webview that links to a webRTC sample.


<x-ms-webview style="left: 0px; top: 0px; width: 100%; height: 100%; position: absolute;" src=""></x-ms-webview>

Answer Source

The question has been answered here:

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.

document.getElementById("webview").addEventListener("MSWebViewPermissionRequested", managePermissionRequest)
function managePermissionRequest(e) {
        if (e.permissionRequest.type == "media") {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download