window.navigator.mediaDevices is undefined

Hey again, sorry for two questions in one day (lol).

So I've got a web page using the CDN copies of the SDK:

<script src="https://sdk-cdn.mypurecloud.com/javascript/147.0.0/purecloud-platform-client-v2.min.js"></script>

And I've been going through the tutorial here (my code is basically the same, except for the access token, obviously :laughing:). The Firefox developer tools (on Windows 10 x64) log "[webrtc-sdk] Authenticated user. Initializing server logging null" and then throw this:

"Uncaught TypeError: window.navigator.mediaDevices is undefined
value media.ts:680
u media.ts:52
v client.ts:147
init.js:15"

Now init.js is mine, but these others (which appear to be in TypeScript?) point at SDK stuff. I can use Genesys Cloud in this version of Firefox (version 91.7.1esr on Windows 10 64-bit) so I'm sure it's something I'm doing incorrectly... but my code is pretty much identical to the tutorial so I'm kind of at a loss here. Here's the code, just cuz...

sdk = new GenesysCloudWebrtcSdk({ accessToken: aVariableIknowIsaValidAccessToken_lol });
sdk.on('sdkError', function(event) {
console.log("SDK error: ", event);
});
sdk.on('pendingSession', function(event) {
console.log("Call incoming: ", event);
});
sdk.on('sessionStarted', function(event) {
console.log("Call started: ", event);
});
sdk.on('sessionEnded', function(event) {
console.log("Call ended: ", event);
});
sdk.initialize().then(() => {
console.log("SDK loaded.");
});

I noticed the docs talk about some kind of "media utilities" in random places (not linked to from the quick start)... so I need to do some kind of "pre-initialization initialization" here or what? :laughing:

So this is strange and seems to indicate something wrong with your browser. window.navigator.mediaDevices is a native API that should be available in basically all browsers. Navigator.mediaDevices - Web APIs | MDN. Oh, now that I think about it, you might have to be running your app in a secure context (https) which isn't always done as developers. Can you verify that's the case?

That's the only explanation that makes sense. Guess the Firefox team forgot to update the error to reflect the actual problem lol. Even that MDN link says HTTPS is required. Guess I'll have to bug IT to put an SSL cert on our dev server.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.