From a72160dff9ed4ba24b4832752e8c3e59704f6afa Mon Sep 17 00:00:00 2001 From: williamito Date: Wed, 18 Dec 2024 11:26:21 -0800 Subject: [PATCH 1/2] Add Colab workaround to web components troubleshooting docs --- docs/web-components/troubleshooting.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/web-components/troubleshooting.md b/docs/web-components/troubleshooting.md index 25aac8082..6c18c0750 100644 --- a/docs/web-components/troubleshooting.md +++ b/docs/web-components/troubleshooting.md @@ -71,3 +71,16 @@ You can fix this Trusted Types error by disabling Trusted Types in the security ) ) ``` + +## Colab + +### Site level user permissions + +Some APIs like `[navigator.mediaDevices.getUserMedia()](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)` require that users grant permission through a browser prompt. Colab attempts to detect if a code cell requires user permission, but this detection does not work for Mesop apps running in Colab using `me.colab_run()`. + +As a workaround, use the IPython `%%javascript` cell magic to trigger a user permission prompt. Once permission is granted, it applies to all cells in the notebook. For example, to request the `microphone` permission, create a new code cell and run the following code: + +``` +%%javascript +navigator.mediaDevices.getUserMedia({audio: true, video: false}); +``` From f0657ef2765f7c0ccfd521e9dffbe3cd10e9ae0a Mon Sep 17 00:00:00 2001 From: williamito Date: Wed, 18 Dec 2024 11:29:28 -0800 Subject: [PATCH 2/2] Fix markdown --- docs/web-components/troubleshooting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/web-components/troubleshooting.md b/docs/web-components/troubleshooting.md index 6c18c0750..8797abe72 100644 --- a/docs/web-components/troubleshooting.md +++ b/docs/web-components/troubleshooting.md @@ -76,7 +76,7 @@ You can fix this Trusted Types error by disabling Trusted Types in the security ### Site level user permissions -Some APIs like `[navigator.mediaDevices.getUserMedia()](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)` require that users grant permission through a browser prompt. Colab attempts to detect if a code cell requires user permission, but this detection does not work for Mesop apps running in Colab using `me.colab_run()`. +Some APIs like [`navigator.mediaDevices.getUserMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) require that users grant permission through a browser prompt. Colab attempts to detect if a code cell requires user permission, but this detection does not work for Mesop apps running in Colab using `me.colab_run()`. As a workaround, use the IPython `%%javascript` cell magic to trigger a user permission prompt. Once permission is granted, it applies to all cells in the notebook. For example, to request the `microphone` permission, create a new code cell and run the following code: