Skip to content

Commit

Permalink
fix: ff quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
myandrienko committed Oct 30, 2024
1 parent 81fa229 commit 8ba1e8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/devices/BrowserPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class BrowserPermission {

this.ready = (async () => {
const assumeGranted = (error?: unknown) => {
this.setState('granted');
this.setState('prompt');
};

if (!canQueryPermissions()) {
Expand Down
13 changes: 7 additions & 6 deletions packages/client/src/devices/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { getLogger } from '../logger';
import { BrowserPermission } from './BrowserPermission';
import { lazy } from '../helpers/lazy';
import { isFirefox } from '../helpers/browsers';

/**
* Returns an Observable that emits the list of available devices
Expand Down Expand Up @@ -160,12 +161,12 @@ export const getAudioOutputDevices = lazy(() => {

const getStream = async (constraints: MediaStreamConstraints) => {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
// On Firefox, there's no reliable way to listen to device permission changes,
// so it's difficult to update the device list once camera or microphone access
// is allowed by the user. However, if we were able to get user media, we can be
// sure permission was granted, so we fake the devicechange event to force device
// lists to update.
navigator.mediaDevices.dispatchEvent(new Event('devicechange'));
if (isFirefox()) {
// When enumerating devices, Firefox will hide device labels unless there's been
// an active user media stream on the page. So we force device list updates after
// every successful getUserMedia call.
navigator.mediaDevices.dispatchEvent(new Event('devicechange'));
}
return stream;
};

Expand Down

0 comments on commit 8ba1e8c

Please sign in to comment.