{"pageContext":{"article":{"title":"How to enable the camera, microphone, or WebRTC","id":"webrtc","description":"An explanation of how to enable the camera, microphone, or WebRTC using 3D WebView.","createdDate":"2020-08-09","updatedDate":"2026-04-22","content":"Like a normal web browser, 3D WebView blocks web pages from accessing the device's camera and microphone by default. However, applications can use [Web.SetCameraAndMicrophoneEnabled()](https://developer.vuplex.com/webview/Web#SetCameraAndMicrophoneEnabled) to enable camera and microphone access. On Windows, no additional configuration is needed. However, on macOS, Android, iOS, WebGL, and UWP additional project configuration is needed in order to successfully grant camera and microphone access:\n\n- [macOS camera and mic access](#mac)\n- [Android camera and mic access](#android)\n- [iOS camera and mic access](#ios)\n- [WebGL camera and mic access](#webgl)\n- [UWP camera and mic access](#uwp)\n\nFor additional WebRTC topics, please see these sections:\n\n- [How to select which camera, microphone, or speaker is used](#select-media)\n- [How to share video from a Unity camera on a video call?](/articles/unity-camera-video-call)\n\n<h2 id=\"mac\">macOS camera and mic access</h2>\n\nFor macOS, the following two steps are required in addition to calling [Web.SetCameraAndMicrophoneEnabled()](https://developer.vuplex.com/webview/Web#SetCameraAndMicrophoneEnabled):\n\n1. To use the camera and microphone while running in the macOS Unity editor, it's necessary to go to the macOS [System Settings](https://support.apple.com/guide/mac-help/change-system-settings-mh15217/mac) app, click \"Privacy & Security\", and then use the \"Camera\" and \"Microphone\" menu options to enable camera and microphone access for Unity Hub.\n\n![macOS security settings](/article-assets/20200809-webrtc/mac-security-settings.jpg)\n![macOS camera settings](/article-assets/20200809-webrtc/mac-camera-settings.jpg)\n![macOS mic settings](/article-assets/20200809-webrtc/mac-mic-settings.jpg)\n\n2. To use the camera and microphone in a macOS player build, it's necessary to go to Unity macOS Player Settings -> Other Settings -> Configuration and fill in text for the \"Camera Usage Description\" and \"Microphone Usage Description\" fields:\n\n![macOS player settings](/article-assets/20200809-webrtc/mac-player-settings.jpg)\n\n<h2 id=\"android\">Android camera and mic access</h2>\n\nFor Android, the application can either enable camera and microphone access together with [Web.SetCameraAndMicrophoneEnabled()](https://developer.vuplex.com/webview/Web#SetCameraAndMicrophoneEnabled) or separately with [AndroidWebView.SetCameraEnabled()](https://developer.vuplex.com/webview/AndroidWebView#SetCameraEnabled) and [SetMicrophoneEnabled()](https://developer.vuplex.com/webview/AndroidWebView#SetMicrophoneEnabled). In addition to calling one of these methods, the following steps are required in order to enable camera and/or microphone access:\n\n1. The application's [AndroidManifest.xml file](https://docs.unity3d.com/Manual/android-manifest.html) must include the following permissions, as demonstrated in <a download=\"AndroidManifest.xml\" href=\"/article-assets/20200809-webrtc/AndroidManifest.xml\">this example AndroidManifest.xml file</a>:\n    - [RECORD_AUDIO](https://developer.android.com/reference/android/Manifest.permission#RECORD_AUDIO)\n    - [MODIFY_AUDIO_SETTINGS](https://developer.android.com/reference/android/Manifest.permission#MODIFY_AUDIO_SETTINGS)\n    - [CAMERA](https://developer.android.com/reference/android/Manifest.permission#CAMERA)\n\n2. The application must also [request camera and microphone permissions at runtime](https://docs.unity3d.com/Manual/android-RequestingPermissions.html). Alternatively, during development, you can manually grant camera and microphone permissions to the app [via the Android Settings app](https://support.google.com/android/answer/9431959).\n\n<h2 id=\"ios\">iOS camera and mic access</h2>\n\nFor iOS, enabling the camera and microphone is only supported in iOS 15 or newer and is only supported in [Native 2D Mode](/articles/native-2d-mode). The application can either enable camera and microphone access together with [Web.SetCameraAndMicrophoneEnabled()](https://developer.vuplex.com/webview/Web#SetCameraAndMicrophoneEnabled) or separately with [iOSWebView.SetCameraEnabled()](https://developer.vuplex.com/webview/iOSWebView#SetCameraEnabled) and [SetMicrophoneEnabled()](https://developer.vuplex.com/webview/iOSWebView#SetMicrophoneEnabled). In addition to calling one of these methods, you must also enter text for the \"Camera Usage Description\" and \"Microphone Usage Description\" in iOS Player Settings -> Other Settings:\n\n![iOS camera and mic player settings](/article-assets/20200809-webrtc/ios-camera-mic-settings.jpg)\n\n- The first time that a web page tries to access the camera or microphone, the operating system displays permission prompts containing the text that you entered for the camera and microphone usage descriptions in Player Settings. If the user grants permission, then this step occurs only once, and the permission prompts aren't shown on subsequent runs of the app.\n\n- If the application programmatically enabled camera and/or microphone permission by calling [Web.SetCameraAndMicrophoneEnabled()](https://developer.vuplex.com/webview/Web#SetCameraAndMicrophoneEnabled), [iOSWebView.SetCameraEnabled()](https://developer.vuplex.com/webview/iOSWebView#SetCameraEnabled), or [SetMicrophoneEnabled()](https://developer.vuplex.com/webview/iOSWebView#SetMicrophoneEnabled), then no further permission prompts will be shown to the user, and web pages will be able to access the camera and/or microphone. If the application did not programmatically enable camera or microphone permission by calling one of those APIs, then the default behavior is that when a web page tries to access the camera or microphone, the webview shows a second set of permission prompts to the user asking for permission for that specific website. Unlike the first permission prompt, this one is reshown every time the app runs.\n\n- Not all websites that use the camera and microphone correctly support mobile Safari. [Here's an example](https://webcammictest.com/) of one that does, which can be used for testing.\n\n<h2 id=\"webgl\">WebGL camera and mic access</h2>\n\nFor WebGL, if the Unity WebGL app is loaded in a Chromium based browser (e.g. Chrome, Edge, Opera) or in FireFox, then no additional steps are required in addition to calling [Web.SetCameraAndMicrophoneEnabled()](https://developer.vuplex.com/webview/Web#SetCameraAndMicrophoneEnabled). However, if the Unity WebGL app is loaded in Safari (i.e. on iOS or macOS), then there is an additional limitation that you should be aware of, which is that Safari only allows camera and microphone access if the Unity WebGL app is loaded from an `https://` URL or from localhost (i.e. `http://localhost:{port}`). If the Unity WebGL app is loaded from an unsecure `http://` URL other than localhost, then Safari will block camera and microphone access (i.e. [navigator.mediaDevices](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/mediaDevices) will be undefined). In other words, in order to be able to access the camera or microphone on iOS or macOS, your Unity WebGL app must be served over HTTPS. For an example of a Unity WebGL site served over HTTPS that enables camera and microphone permissions, please the [WebGL WebView Demo](https://webgldemo.vuplex.com/).\n\n<h2 id=\"uwp\">UWP camera and mic access</h2>\n\nFor UWP, in addition to calling [Web.SetCameraAndMicrophoneEnabled()](https://developer.vuplex.com/webview/Web#SetCameraAndMicrophoneEnabled), you must also enable the \"WebCam\" and \"Microphone\" capabilities in UWP Player Settings -> Publishing Settings. Also, if you have an existing UWP build directory, you will need to delete it after adding these capabilities so that Unity regenerates the app's manifest file with the new capabilities.\n\n![UWP camera and mic player settings](/article-assets/20200809-webrtc/uwp-camera-mic-settings.jpg)\n\n<h2 id=\"select-media\">How to select which camera, microphone, or speaker is used</h2>\n\nFor WebRTC, the web page itself can choose which camera, microphone, and speaker is used by calling the [enumerateDevices()](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices) JavaScript API to view the available devices. For more info, please see the following resources:\n\n- [WebRTC example for selecting camera, microphone, and speaker](https://webrtc.github.io/samples/src/content/devices/input-output/)\n- [Chrome Dev Blog: Choose cameras, microphones and speakers from your web app](https://developer.chrome.com/blog/media-devices/)\n"}}}