Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): getting TypeError when browser is missing navigator.mediaDevices #211

Open
theonetheycallneo opened this issue Aug 26, 2023 · 0 comments

Comments

@theonetheycallneo
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @vatom/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@vatom/hifi-spatial-audio/dist/utilities/HiFiUtilities.js b/node_modules/@vatom/hifi-spatial-audio/dist/utilities/HiFiUtilities.js
index d4aa9c7..dd1c0c7 100644
--- a/node_modules/@vatom/hifi-spatial-audio/dist/utilities/HiFiUtilities.js
+++ b/node_modules/@vatom/hifi-spatial-audio/dist/utilities/HiFiUtilities.js
@@ -123,13 +123,19 @@ export class HiFiUtilities {
             "window.RTCSessionDescription"
         ];
         for (let i = 0; i < requiredFeatures.length; i++) {
-            if (typeof (eval(requiredFeatures[i])) === "undefined") {
-                HiFiLogger.error("HiFi Audio API: The browser does not support: " + requiredFeatures[i]);
-                if (requiredFeatures[i] === "navigator.mediaDevices.getUserMedia") {
-                    HiFiLogger.error("HiFi Audio API: Your browser may be preventing access to this feature if you are running in an insecure context, i.e. an `http` server.");
+            try {
+                if (typeof (eval(requiredFeatures[i])) === "undefined") {
+                    HiFiLogger.error("HiFi Audio API: The browser does not support: " + requiredFeatures[i]);
+                    if (requiredFeatures[i] === "navigator.mediaDevices.getUserMedia") {
+                        HiFiLogger.error("HiFi Audio API: Your browser may be preventing access to this feature if you are running in an insecure context, i.e. an `http` server.");
+                    }
+                    return false;
                 }
-                return false;
+            } catch (error) {
+                console.error('[HiFiUtilities.js]', error)
+                return false
             }
+            
         }
         return true;
     }

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant