Function to update the visibility of the media settings modal.
Param: options.parameters.showAlert
Optional function to show alert messages.
Param: options.parameters.switchUserVideo
Function to switch the user's video input.
Returns
A promise that resolves when the video input has been switched.
Remarks
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.
Example
constoptions: 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: () => ({ }), }, };
Switches the user's video device based on the provided video preference.
Param: options
The options for switching the video input.
Param: options.videoPreference
The preferred video device to switch to.
Param: options.parameters
The parameters required for switching the video input.
Param: options.parameters.recordStarted
Indicates if recording has started.
Param: options.parameters.recordResumed
Indicates if recording has resumed.
Param: options.parameters.recordStopped
Indicates if recording has stopped.
Param: options.parameters.recordPaused
Indicates if recording is paused.
Param: options.parameters.recordingMediaOptions
The current media options (e.g., "video").
Param: options.parameters.videoAlreadyOn
Indicates if the video is currently on.
Param: options.parameters.userDefaultVideoInputDevice
The default video input device for the user.
Param: options.parameters.defVideoID
The default video ID for the input device.
Param: options.parameters.allowed
Indicates if the user is allowed to switch video.
Param: options.parameters.updateDefVideoID
Function to update the default video ID.
Param: options.parameters.updatePrevVideoInputDevice
Function to update the previous video input device.
Param: options.parameters.updateUserDefaultVideoInputDevice
Function to update the user’s default video input device.
Param: options.parameters.updateIsMediaSettingsModalVisible
Function to update the visibility of the media settings modal.
Param: options.parameters.showAlert
Optional function to show alert messages.
Param: options.parameters.switchUserVideo
Function to switch the user's video input.
Returns
A promise that resolves when the video input has been switched.
Remarks
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.
Example