Switches the user's video device based on the provided video preference.

The options for switching the video input.

The preferred video device to switch to.

The parameters required for switching the video input.

Indicates if recording has started.

Indicates if recording has resumed.

Indicates if recording has stopped.

Indicates if recording is paused.

The current media options (e.g., "video").

Indicates if the video is currently on.

The default video input device for the user.

The default video ID for the input device.

Indicates if the user is allowed to switch video.

Function to update the default video ID.

Function to update the previous video input device.

Function to update the user’s default video input device.

Function to update the visibility of the media settings modal.

Optional function to show alert messages.

Function to switch the user's video input.

A promise that resolves when the video input has been switched.

This function checks if the user is allowed to switch the video input based on the current state, and it shows alerts if there are any issues. If the video is already on, it cannot be switched until it is turned off, and vice versa. The default video input device is updated if necessary.

const options: SwitchVideoOptions = {
videoPreference: 'newDeviceId',
parameters: {
recordStarted: false,
recordResumed: false,
recordStopped: false,
recordPaused: false,
recordingMediaOptions: 'video',
videoAlreadyOn: true,
userDefaultVideoInputDevice: 'currentDeviceId',
defVideoID: 'defaultDeviceId',
allowed: true,
updateDefVideoID: (deviceId) => console.log(`Default video ID updated to: ${deviceId}`),
updatePrevVideoInputDevice: (deviceId) => console.log(`Previous video input device updated to: ${deviceId}`),
updateUserDefaultVideoInputDevice: (deviceId) => console.log(`User default video input device updated to: ${deviceId}`),
updateIsMediaSettingsModalVisible: (isVisible) => console.log(`Media settings modal is now ${isVisible ? 'visible' : 'hidden'}`),
switchUserVideo: async ({ videoPreference }) => console.log(`Switched video to: ${videoPreference}`),
getUpdatedAllParams: () => ({ }),
},
};

const switchVideoService = new SwitchVideo();
await switchVideoService.switchVideo(options);

Constructors

Methods

Constructors

Methods