Skip to content

Commit

Permalink
feat(JitsiMediaDevices) don't initialize in the constructor
Browse files Browse the repository at this point in the history
It's very odd to start receiving events and logs about device changes
when lib-jitsi-meet has not been initialized yet.

Delay initialization until JitsiMeetJS.init has been called, which is
the very first thing users need to call anyway.
  • Loading branch information
saghul committed May 13, 2024
1 parent cf4276b commit 142c441
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions JitsiMediaDevices.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ class JitsiMediaDevices extends Listenable {
constructor() {
super();
this._permissions = {};
}

/**
* Initialize. Start listening for device changes and initialize permissions checks.
*/
init() {
RTC.addListener(
RTCEvents.DEVICE_LIST_CHANGED,
devices =>
Expand Down Expand Up @@ -89,7 +94,6 @@ class JitsiMediaDevices extends Listenable {
});
}


/**
* Parses a PermissionState object and returns true for granted and false otherwise.
*
Expand Down Expand Up @@ -130,7 +134,7 @@ class JitsiMediaDevices extends Listenable {
this.eventEmitter.emit(JitsiMediaDevicesEvents.PERMISSIONS_CHANGED, this._permissions);

if (this._permissions[MediaType.AUDIO] || this._permissions[MediaType.VIDEO]) {
// Triggering device list update when the permissiions are granted in order to update
// Triggering device list update when the permissions are granted in order to update
// the labels the devices.
// eslint-disable-next-line no-empty-function
this.enumerateDevices(() => {});
Expand Down
1 change: 1 addition & 0 deletions JitsiMeetJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default {
// @ts-ignore
logger.info(`This appears to be ${browser.getName()}, ver: ${browser.getVersion()}`);

JitsiMediaDevices.init();
Settings.init(options.externalStorage);
Statistics.init(options);

Expand Down

0 comments on commit 142c441

Please sign in to comment.